Class: 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
Attributes inherited from CacheBase
#adapter, #cache, #features_cache_key, #ttl
Instance Method Summary collapse
- #disable(feature, gate, thing) ⇒ Object
- #enable(feature, gate, thing) ⇒ Object
-
#initialize(adapter, cache, ttl = nil, expires_in: :none_provided, write_through: false, prefix: nil) ⇒ ActiveSupportCacheStore
constructor
A new instance of ActiveSupportCacheStore.
- #remove(feature) ⇒ Object
Methods inherited from CacheBase
#add, #clear, #expire_feature_cache, #expire_features_cache, #feature_cache_key, #features, #get, #get_all, #get_multi
Methods included from Flipper::Adapter
#default_config, #export, #get_all, #get_multi, #import, included, #name, #read_only?
Constructor Details
#initialize(adapter, cache, ttl = nil, expires_in: :none_provided, write_through: false, prefix: nil) ⇒ ActiveSupportCacheStore
Returns a new instance of ActiveSupportCacheStore.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 10 def initialize(adapter, cache, ttl = nil, expires_in: :none_provided, 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) @write_through = write_through end |
Instance Method Details
#disable(feature, gate, thing) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 45 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
35 36 37 38 39 40 41 42 43 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 35 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
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/flipper/adapters/active_support_cache_store.rb', line 24 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 |