chore(flipper): enable caching in memory

This commit is contained in:
Colin Darie 2024-03-02 16:37:03 +01:00
parent 2d22737823
commit 3519e5eef1
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
3 changed files with 19 additions and 0 deletions

View file

@ -33,6 +33,7 @@ gem 'dotenv-rails', require: 'dotenv/rails-now' # dotenv should always be loaded
gem 'dry-monads'
gem 'flipper'
gem 'flipper-active_record'
gem 'flipper-active_support_cache_store'
gem 'flipper-ui'
gem 'fugit'
gem 'geocoder'

View file

@ -237,6 +237,9 @@ GEM
flipper-active_record (1.2.2)
activerecord (>= 4.2, < 8)
flipper (~> 1.2.2)
flipper-active_support_cache_store (1.2.2)
activesupport (>= 4.2, < 8)
flipper (~> 1.2.2)
flipper-ui (1.2.2)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 1.2.2)
@ -833,6 +836,7 @@ DEPENDENCIES
factory_bot
flipper
flipper-active_record
flipper-active_support_cache_store
flipper-ui
fugit
geo_coord

View file

@ -1,6 +1,10 @@
# This setup is primarily for first deployment, because consequently
# we can add new features from the Web UI. However when the new DB is created
# this will immediately migrate the default features to be controlled.
#
require 'flipper/adapters/active_record'
require 'flipper/adapters/active_support_cache_store'
def setup_features(features)
existing = Flipper.preload(features).map { _1.name.to_sym }
missing = features - existing
@ -41,6 +45,16 @@ ActiveSupport.on_load(:active_record) do
end
end
Flipper.configure do |config|
config.adapter do
Flipper::Adapters::ActiveSupportCacheStore.new(
Flipper::Adapters::ActiveRecord.new,
ActiveSupport::Cache::MemoryStore.new,
expires_in: 10.seconds
)
end
end
Rails.application.configure do
config.flipper.strict = Rails.env.development?
end