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:
Rémy Coutable 2017-06-21 16:35:14 +02:00
parent 0551364c60
commit b8a7b59d82
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,4 @@
require 'flipper/middleware/memoizer'
Rails.application.config.middleware.use Flipper::Middleware::Memoizer,
lambda { Feature.flipper }

View file

@ -39,7 +39,6 @@ class Feature
get(key).disable get(key).disable
end end
private
def flipper def flipper
@flipper ||= begin @flipper ||= begin