Module: Ukiryu::ToolCache Private
- Defined in:
- lib/ukiryu/tool_cache.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Cache management for Tool instances
Provides centralized cache management for tool instances, with bounded LRU caching to prevent memory bloat.
Class Method Summary collapse
-
.cache ⇒ Cache
private
Get the tools cache (bounded LRU cache).
-
.cache_key_for(name, options) ⇒ String
private
Generate a cache key for a tool.
-
.clear ⇒ void
private
Clear the tool cache.
-
.clear_definition_cache ⇒ void
private
Clear the definition cache only.
-
.get(key) ⇒ Tool?
private
Get a tool from the cache.
-
.set(key, tool) ⇒ void
private
Store a tool in the cache.
Class Method Details
.cache ⇒ Cache
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the tools cache (bounded LRU cache)
15 16 17 |
# File 'lib/ukiryu/tool_cache.rb', line 15 def cache @cache ||= Ukiryu::Cache.new(max_size: 50, ttl: 3600) end |
.cache_key_for(name, options) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate a cache key for a tool
Cache keys are composed of: name-platform-shell-version to ensure different environments get different cached instances.
47 48 49 50 51 52 53 |
# File 'lib/ukiryu/tool_cache.rb', line 47 def cache_key_for(name, ) runtime = Ukiryu::Runtime.instance platform = [:platform] || runtime.platform shell = [:shell] || runtime.shell version = [:version] || 'latest' "#{name}-#{platform}-#{shell}-#{version}" end |
.clear ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Clear the tool cache
Also clears the Tools::Generator cache.
60 61 62 63 |
# File 'lib/ukiryu/tool_cache.rb', line 60 def clear cache.clear Ukiryu::Tools::Generator.clear_cache end |
.clear_definition_cache ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Clear the definition cache only
Clears the Definition::Loader cache without clearing tool instances.
70 71 72 |
# File 'lib/ukiryu/tool_cache.rb', line 70 def clear_definition_cache Ukiryu::Definition::Loader.clear_cache end |
.get(key) ⇒ Tool?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a tool from the cache
23 24 25 |
# File 'lib/ukiryu/tool_cache.rb', line 23 def get(key) cache[key] end |
.set(key, tool) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Store a tool in the cache
32 33 34 |
# File 'lib/ukiryu/tool_cache.rb', line 32 def set(key, tool) cache[key] = tool end |