diff --git a/lib/flipper/adapters/cache_store.rb b/lib/flipper/adapters/cache_store.rb index 0b3e76c6d..083c9d3cd 100644 --- a/lib/flipper/adapters/cache_store.rb +++ b/lib/flipper/adapters/cache_store.rb @@ -22,16 +22,17 @@ def self.key_for(key) attr_reader :name # Public - def initialize(adapter, cache, options = nil) + def initialize(adapter, cache, expires_in: nil) @adapter = adapter @name = :cache_store @cache = cache - @options = options + @write_options = {} + @write_options.merge!(expires_in: expires_in) if expires_in end # Public def features - @cache.fetch(FeaturesKey, @options) do + @cache.fetch(FeaturesKey, @write_options) do @adapter.features end end @@ -39,28 +40,28 @@ def features # Public def add(feature) result = @adapter.add(feature) - @cache.delete(FeaturesKey, @options) + @cache.delete(FeaturesKey) result end ## Public def remove(feature) result = @adapter.remove(feature) - @cache.delete(FeaturesKey, @options) - @cache.delete(key_for(feature.key), @options) + @cache.delete(FeaturesKey) + @cache.delete(key_for(feature.key)) result end ## Public def clear(feature) result = @adapter.clear(feature) - @cache.delete(key_for(feature.key), @options) + @cache.delete(key_for(feature.key)) result end ## Public def get(feature) - @cache.fetch(key_for(feature.key), @options) do + @cache.fetch(key_for(feature.key), @write_options) do @adapter.get(feature) end end @@ -72,7 +73,7 @@ def get_multi(features) if uncached_features.any? response = @adapter.get_multi(uncached_features) response.each do |key, value| - @cache.write(key_for(key), value, @options) + @cache.write(key_for(key), value, @write_options) result[key] = value end end @@ -82,14 +83,14 @@ def get_multi(features) ## Public def enable(feature, gate, thing) result = @adapter.enable(feature, gate, thing) - @cache.delete(key_for(feature.key), @options) + @cache.delete(key_for(feature.key)) result end ## Public def disable(feature, gate, thing) result = @adapter.disable(feature, gate, thing) - @cache.delete(key_for(feature.key), @options) + @cache.delete(key_for(feature.key)) result end