Skip to content

Commit 573aded

Browse files
committed
adds race_condition_ttl option for the ActiveSupportCacheStore adapter
1 parent 87e8674 commit 573aded

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/flipper/adapters/active_support_cache_store.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ module Flipper
66
module Adapters
77
# Public: Adapter that wraps another adapter with the ability to cache
88
# adapter calls in ActiveSupport::ActiveSupportCacheStore caches.
9+
10+
# Public: The race_condition_ttl for all cached data.
11+
attr_reader :race_condition_ttl
12+
913
class ActiveSupportCacheStore < CacheBase
10-
def initialize(adapter, cache, ttl = nil, expires_in: :none_provided, write_through: false, prefix: nil)
14+
def initialize(adapter, cache, ttl = nil, expires_in: :none_provided, race_condition_ttl: nil, write_through: false, prefix: nil)
1115
if expires_in == :none_provided
1216
ttl ||= nil
1317
else
@@ -18,6 +22,7 @@ def initialize(adapter, cache, ttl = nil, expires_in: :none_provided, write_thro
1822
ttl = expires_in
1923
end
2024
super(adapter, cache, ttl, prefix: prefix)
25+
@race_condition_ttl = race_condition_ttl
2126
@write_through = write_through
2227
end
2328

@@ -73,6 +78,7 @@ def cache_delete(key)
7378
def write_options
7479
write_options = {}
7580
write_options[:expires_in] = @ttl if @ttl
81+
write_options[:race_condition_ttl] if @race_condition_ttl
7682
write_options
7783
end
7884
end

0 commit comments

Comments
 (0)