Class: Ukiryu::Shell::InstanceCache
- Inherits:
-
Object
- Object
- Ukiryu::Shell::InstanceCache
- Defined in:
- lib/ukiryu/shell/instance_cache.rb
Overview
Cached shell instances for performance
Reuses shell instances to avoid repeated object creation in hot paths. Thread-safe using Mutex.
Class Method Summary collapse
-
.clear ⇒ Object
Clear the cache (mainly for testing).
-
.instance_for(name) ⇒ Shell::Base
Get a cached shell instance for the given shell name.
-
.size ⇒ Integer
Get cache size (for debugging).
Class Method Details
.clear ⇒ Object
Clear the cache (mainly for testing)
28 29 30 31 32 |
# File 'lib/ukiryu/shell/instance_cache.rb', line 28 def clear @mutex.synchronize do @cache.clear end end |
.instance_for(name) ⇒ Shell::Base
Get a cached shell instance for the given shell name
20 21 22 23 24 |
# File 'lib/ukiryu/shell/instance_cache.rb', line 20 def instance_for(name) @mutex.synchronize do @cache[name] ||= create_instance(name) end end |
.size ⇒ Integer
Get cache size (for debugging)
38 39 40 41 42 |
# File 'lib/ukiryu/shell/instance_cache.rb', line 38 def size @mutex.synchronize do @cache.size end end |