Class: Flipper::Adapters::ActiveSupportCacheStore
- Inherits:
-
CacheBase
- Object
- CacheBase
- Flipper::Adapters::ActiveSupportCacheStore
- Defined in:
- lib/flipper/adapters/active_support_cache_store.rb
Overview
Public: Adapter that wraps another adapter with the ability to cache adapter calls in ActiveSupport::ActiveSupportCacheStore caches.
Instance Attribute Summary collapse
-
#race_condition_ttl ⇒ Object
readonly
Public: The race_condition_ttl for all cached data.
Instance Method Summary collapse
- #disable(feature, gate, thing) ⇒ Object
- #enable(feature, gate, thing) ⇒ Object
-
#initialize(adapter, cache, ttl = nil, expires_in: :none_provided, race_condition_ttl: nil, write_through: false, prefix: nil) ⇒ ActiveSupportCacheStore
constructor
A new instance of ActiveSupportCacheStore.
- #remove(feature) ⇒ Object
Constructor Details
#initialize(adapter, cache, ttl = nil, expires_in: :none_provided, race_condition_ttl: nil, write_through: false, prefix: nil) ⇒ ActiveSupportCacheStore
Returns a new instance of ActiveSupportCacheStore.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 14 def initialize(adapter, cache, ttl = nil, expires_in: :none_provided, race_condition_ttl: nil, write_through: false, prefix: nil) if expires_in == :none_provided ttl ||= nil else warn "DEPRECATION WARNING: The `expires_in` kwarg is deprecated for " + "Flipper::Adapters::ActiveSupportCacheStore and will be removed " + "in the next major version. Please pass in expires in as third " + "argument instead." ttl = expires_in end super(adapter, cache, ttl, prefix: prefix) @race_condition_ttl = race_condition_ttl @write_through = write_through end |
Instance Attribute Details
#race_condition_ttl ⇒ Object (readonly)
Public: The race_condition_ttl for all cached data.
12 13 14 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 12 def race_condition_ttl @race_condition_ttl end |
Instance Method Details
#disable(feature, gate, thing) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 50 def disable(feature, gate, thing) if @write_through result = @adapter.disable(feature, gate, thing) cache_write feature_cache_key(feature.key), @adapter.get(feature) result else super end end |
#enable(feature, gate, thing) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 40 def enable(feature, gate, thing) if @write_through result = @adapter.enable(feature, gate, thing) cache_write feature_cache_key(feature.key), @adapter.get(feature) result else super end end |
#remove(feature) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 29 def remove(feature) if @write_through result = @adapter.remove(feature) expire_features_cache cache_write feature_cache_key(feature.key), default_config result else super end end |