chore(flipper): enable caching in memory
This commit is contained in:
parent
2d22737823
commit
3519e5eef1
3 changed files with 19 additions and 0 deletions
1
Gemfile
1
Gemfile
|
@ -33,6 +33,7 @@ gem 'dotenv-rails', require: 'dotenv/rails-now' # dotenv should always be loaded
|
||||||
gem 'dry-monads'
|
gem 'dry-monads'
|
||||||
gem 'flipper'
|
gem 'flipper'
|
||||||
gem 'flipper-active_record'
|
gem 'flipper-active_record'
|
||||||
|
gem 'flipper-active_support_cache_store'
|
||||||
gem 'flipper-ui'
|
gem 'flipper-ui'
|
||||||
gem 'fugit'
|
gem 'fugit'
|
||||||
gem 'geocoder'
|
gem 'geocoder'
|
||||||
|
|
|
@ -237,6 +237,9 @@ GEM
|
||||||
flipper-active_record (1.2.2)
|
flipper-active_record (1.2.2)
|
||||||
activerecord (>= 4.2, < 8)
|
activerecord (>= 4.2, < 8)
|
||||||
flipper (~> 1.2.2)
|
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)
|
flipper-ui (1.2.2)
|
||||||
erubi (>= 1.0.0, < 2.0.0)
|
erubi (>= 1.0.0, < 2.0.0)
|
||||||
flipper (~> 1.2.2)
|
flipper (~> 1.2.2)
|
||||||
|
@ -833,6 +836,7 @@ DEPENDENCIES
|
||||||
factory_bot
|
factory_bot
|
||||||
flipper
|
flipper
|
||||||
flipper-active_record
|
flipper-active_record
|
||||||
|
flipper-active_support_cache_store
|
||||||
flipper-ui
|
flipper-ui
|
||||||
fugit
|
fugit
|
||||||
geo_coord
|
geo_coord
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
# This setup is primarily for first deployment, because consequently
|
# 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
|
# 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.
|
# 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)
|
def setup_features(features)
|
||||||
existing = Flipper.preload(features).map { _1.name.to_sym }
|
existing = Flipper.preload(features).map { _1.name.to_sym }
|
||||||
missing = features - existing
|
missing = features - existing
|
||||||
|
@ -41,6 +45,16 @@ ActiveSupport.on_load(:active_record) do
|
||||||
end
|
end
|
||||||
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
|
Rails.application.configure do
|
||||||
config.flipper.strict = Rails.env.development?
|
config.flipper.strict = Rails.env.development?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue