Class: Coradoc::Configurable::CacheConfig
- Inherits:
-
ConfigSection
- Object
- ConfigSection
- Coradoc::Configurable::CacheConfig
- Defined in:
- lib/coradoc/configurable.rb
Overview
Cache configuration section
Instance Attribute Summary collapse
-
#backend ⇒ Symbol
Cache storage backend (:memory, :file, :redis).
-
#cache_dir ⇒ String?
Cache directory for file backend.
-
#enabled ⇒ Boolean
Whether caching is enabled.
-
#max_size ⇒ Integer
Maximum cache size (number of entries).
-
#ttl ⇒ Integer
Cache TTL in seconds (0 = no expiry).
Attributes inherited from ConfigSection
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CacheConfig
constructor
A new instance of CacheConfig.
Methods inherited from ConfigSection
#[], #[]=, #after_initialize, #merge!, symbolize_keys, #to_h
Constructor Details
#initialize(options = {}) ⇒ CacheConfig
Returns a new instance of CacheConfig.
124 125 126 127 128 129 130 131 |
# File 'lib/coradoc/configurable.rb', line 124 def initialize( = {}) super @enabled = @options.fetch(:enabled, true) @max_size = @options.fetch(:max_size, 1000) @ttl = @options.fetch(:ttl, 0) @backend = @options.fetch(:backend, :memory) @cache_dir = @options.fetch(:cache_dir, nil) end |
Instance Attribute Details
#backend ⇒ Symbol
Returns Cache storage backend (:memory, :file, :redis).
119 120 121 |
# File 'lib/coradoc/configurable.rb', line 119 def backend @backend end |
#cache_dir ⇒ String?
Returns Cache directory for file backend.
122 123 124 |
# File 'lib/coradoc/configurable.rb', line 122 def cache_dir @cache_dir end |
#enabled ⇒ Boolean
Returns Whether caching is enabled.
110 111 112 |
# File 'lib/coradoc/configurable.rb', line 110 def enabled @enabled end |
#max_size ⇒ Integer
Returns Maximum cache size (number of entries).
113 114 115 |
# File 'lib/coradoc/configurable.rb', line 113 def max_size @max_size end |
#ttl ⇒ Integer
Returns Cache TTL in seconds (0 = no expiry).
116 117 118 |
# File 'lib/coradoc/configurable.rb', line 116 def ttl @ttl end |