Module: Woods::Console::Adapters::CacheAdapter
- Defined in:
- lib/woods/console/adapters/cache_adapter.rb
Overview
Cache adapter that auto-detects the active cache store.
Supports Redis, Solid Cache, memory, and file cache stores. Detection checks Rails.cache class name first, then falls back to checking for SolidCache constant.
Constant Summary collapse
- STORE_PATTERNS =
{ 'RedisCacheStore' => :redis, 'MemoryStore' => :memory, 'FileStore' => :file }.freeze
Class Method Summary collapse
-
.detect ⇒ Symbol
Detect the active cache store backend.
-
.info ⇒ Hash
Get cache store info (backend type, configuration).
-
.stats(namespace: nil) ⇒ Hash
Get cache store statistics.
Class Method Details
.detect ⇒ Symbol
Detect the active cache store backend.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/woods/console/adapters/cache_adapter.rb', line 28 def detect if defined?(::Rails) && ::Rails.respond_to?(:cache) && ::Rails.cache class_name = ::Rails.cache.class.name.to_s STORE_PATTERNS.each do |pattern, backend| return backend if class_name.include?(pattern) end end return :solid_cache if defined?(::SolidCache) :unknown end |
.info ⇒ Hash
Get cache store info (backend type, configuration).
52 53 54 |
# File 'lib/woods/console/adapters/cache_adapter.rb', line 52 def info { tool: 'cache_info', params: {} } end |
.stats(namespace: nil) ⇒ Hash
Get cache store statistics.
45 46 47 |
# File 'lib/woods/console/adapters/cache_adapter.rb', line 45 def stats(namespace: nil) { tool: 'cache_stats', params: { namespace: namespace }.compact } end |