Add the Flipper::Middleware::Memoizer middleware
This ensures we make maximum one call per feature per request. See https://github.com/jnunemaker/flipper/blob/v0.10.2/docs/Optimization.md#memoizing-middleware Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
0551364c60
commit
b8a7b59d82
2 changed files with 4 additions and 1 deletions
4
config/initializers/flipper.rb
Normal file
4
config/initializers/flipper.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
require 'flipper/middleware/memoizer'
|
||||||
|
|
||||||
|
Rails.application.config.middleware.use Flipper::Middleware::Memoizer,
|
||||||
|
lambda { Feature.flipper }
|
|
@ -39,7 +39,6 @@ class Feature
|
||||||
get(key).disable
|
get(key).disable
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def flipper
|
def flipper
|
||||||
@flipper ||= begin
|
@flipper ||= begin
|
||||||
|
|
Loading…
Reference in a new issue