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
#[], #[]=, #merge!, symbolize_keys, #to_h
Constructor Details
#initialize(options = {}) ⇒ CacheConfig
Returns a new instance of CacheConfig.
120 121 122 123 124 125 126 127 |
# File 'lib/coradoc/configurable.rb', line 120 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).
115 116 117 |
# File 'lib/coradoc/configurable.rb', line 115 def backend @backend end |
#cache_dir ⇒ String?
Returns Cache directory for file backend.
118 119 120 |
# File 'lib/coradoc/configurable.rb', line 118 def cache_dir @cache_dir end |
#enabled ⇒ Boolean
Returns Whether caching is enabled.
106 107 108 |
# File 'lib/coradoc/configurable.rb', line 106 def enabled @enabled end |
#max_size ⇒ Integer
Returns Maximum cache size (number of entries).
109 110 111 |
# File 'lib/coradoc/configurable.rb', line 109 def max_size @max_size end |
#ttl ⇒ Integer
Returns Cache TTL in seconds (0 = no expiry).
112 113 114 |
# File 'lib/coradoc/configurable.rb', line 112 def ttl @ttl end |