Class: RubyLLM::Ups::ComponentRegistry
- Inherits:
-
Object
- Object
- RubyLLM::Ups::ComponentRegistry
- Defined in:
- lib/ruby_llm/ups/component_registry.rb
Instance Method Summary collapse
- #clear_cache ⇒ Object
- #find_or_create(name) ⇒ Object
-
#initialize(client) ⇒ ComponentRegistry
constructor
A new instance of ComponentRegistry.
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 |