Allow caching feature flags for a given duration (#14668)
This duration is specified in the `CACHE_FEATURE_FLAGS_SECONDS` environment variable. It can't be updated without restarting the application.
This commit is contained in:
parent
575bce33e7
commit
5fc3f52299
4 changed files with 13 additions and 2 deletions
1
Gemfile
1
Gemfile
|
|
@ -36,6 +36,7 @@ gem "feedjira", "~> 3.2" # A feed fetching and parsing library
|
|||
gem "field_test", "~> 0.4" # A/B testing
|
||||
gem "flipper", "~> 0.22.1" # Feature flipping / flags for Ruby
|
||||
gem "flipper-active_record", "~> 0.22.1" # Store Flipper flags in ActiveRecord
|
||||
gem "flipper-active_support_cache_store", "~> 0.22.1" # Cache feature flags for a short time
|
||||
gem "flipper-ui", "~> 0.22.1"
|
||||
gem "fog-aws", "~> 3.12" # 'fog' gem to support Amazon Web Services
|
||||
gem "front_matter_parser", "~> 1.0" # Parse a front matter from syntactically correct strings or files
|
||||
|
|
|
|||
|
|
@ -278,6 +278,9 @@ GEM
|
|||
flipper-active_record (0.22.1)
|
||||
activerecord (>= 4.2, < 7)
|
||||
flipper (~> 0.22.1)
|
||||
flipper-active_support_cache_store (0.22.1)
|
||||
activesupport (>= 4.2, < 7)
|
||||
flipper (~> 0.22.1)
|
||||
flipper-ui (0.22.1)
|
||||
erubi (>= 1.0.0, < 2.0.0)
|
||||
flipper (~> 0.22.1)
|
||||
|
|
@ -879,6 +882,7 @@ DEPENDENCIES
|
|||
field_test (~> 0.4)
|
||||
flipper (~> 0.22.1)
|
||||
flipper-active_record (~> 0.22.1)
|
||||
flipper-active_support_cache_store (~> 0.22.1)
|
||||
flipper-ui (~> 0.22.1)
|
||||
fog-aws (~> 3.12)
|
||||
front_matter_parser (~> 1.0)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
Flipper.configure do |config|
|
||||
config.default do
|
||||
# pick an adapter, this uses memory, any will do
|
||||
adapter = Flipper::Adapters::ActiveRecord.new
|
||||
adapter = if (cache_duration = ENV["CACHE_FEATURE_FLAGS_SECONDS"])
|
||||
Flipper::Adapters::ActiveSupportCacheStore.new(
|
||||
Flipper::Adapters::ActiveRecord.new,
|
||||
ActiveSupport::Cache::MemoryStore.new(expires_in: cache_duration.to_i.seconds),
|
||||
)
|
||||
else
|
||||
Flipper::Adapters::ActiveRecord.new
|
||||
end
|
||||
|
||||
# pass adapter to handy DSL instance
|
||||
Flipper.new(adapter)
|
||||
|
|
|
|||
BIN
vendor/cache/flipper-active_support_cache_store-0.22.1.gem
vendored
Normal file
BIN
vendor/cache/flipper-active_support_cache_store-0.22.1.gem
vendored
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue