Class: ActiveCachedResource::Configuration
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- ActiveCachedResource::Configuration
- Defined in:
- lib/active_cached_resource/configuration.rb
Constant Summary collapse
- CACHING_STRATEGIES =
{ active_record_sql: ActiveCachedResource::CachingStrategies::SQLCache, active_support_cache: ActiveCachedResource::CachingStrategies::ActiveSupportCache }
- OPTIONS =
%i[cache_key_prefix logger enabled ttl]
Instance Method Summary collapse
-
#initialize(model, options = {}) ⇒ ActiveCachedResource::Configuration
constructor
Initializes a new configuration for the given model with the specified options.
-
#off! ⇒ void
Disables caching.
-
#on! ⇒ void
Enables caching.
Constructor Details
#initialize(model, options = {}) ⇒ ActiveCachedResource::Configuration
Note:
If ‘cache_store` is provided and is a CachingStrategies::Base instance, it will be used as the cache strategy. Otherwise, `cache_strategy` must be provided to determine the cache strategy.
Initializes a new configuration for the given model with the specified options.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/active_cached_resource/configuration.rb', line 31 def initialize(model, = {}) super( { cache: determine_cache_strategy([:cache_store], [:cache_strategy]), cache_key_prefix: model.name.underscore, logger: ActiveCachedResource::Logger.new(model.name), enabled: true, ttl: 86400 }.merge(.slice(*OPTIONS)) ) end |
Instance Method Details
#off! ⇒ void
This method returns an undefined value.
Disables caching.
53 54 55 |
# File 'lib/active_cached_resource/configuration.rb', line 53 def off! self.enabled = false end |
#on! ⇒ void
This method returns an undefined value.
Enables caching.
46 47 48 |
# File 'lib/active_cached_resource/configuration.rb', line 46 def on! self.enabled = true end |