Class: RubyLLM::Ups::ComponentRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/ups/component_registry.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ComponentRegistry

Returns a new instance of ComponentRegistry.



6
7
8
9
10
# File 'lib/ruby_llm/ups/component_registry.rb', line 6

def initialize(client)
  @client = client
  @cache = {}
  @mutex = Mutex.new
end

Instance Method Details

#clear_cache ⇒ Object



21
22
23
# File 'lib/ruby_llm/ups/component_registry.rb', line 21

def clear_cache
  @mutex.synchronize { @cache.clear }
end

#find_or_create(name) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/ruby_llm/ups/component_registry.rb', line 12

def find_or_create(name)
  @mutex.synchronize { return @cache[name] if @cache[name] }

  component = find_by_name(name) || create_component(name)

  @mutex.synchronize { @cache[name] = component }
  component
end