docs/Optimization.md in flipper-0.15.0 vs docs/Optimization.md in flipper-0.16.0
- old
+ new
@@ -13,21 +13,18 @@
Flipper.new(...)
end
end
# This assumes you setup a default flipper instance using configure.
-require 'flipper/middleware/memoizer'
config.middleware.use Flipper::Middleware::Memoizer
```
**Note**: Be sure that the middleware is high enough up in your stack that all feature checks are wrapped.
**Also Note**: If you haven't setup a default instance, you can pass the instance to `SetupEnv` as `Memoizer` uses whatever is setup in the `env`:
```ruby
-require 'flipper/middleware/setup_env'
-require 'flipper/middleware/memoizer'
config.middleware.use Flipper::Middleware::SetupEnv, -> { Flipper.new(...) }
config.middleware.use Flipper::Middleware::Memoizer
```
### Options
@@ -76,11 +73,10 @@
Initialize `RedisCache` with a flipper [adapter](https://github.com/jnunemaker/flipper/blob/master/docs/Adapters.md), a Redis client instance, and an optional TTL in seconds. TTL defaults to 3600 seconds.
Example using the RedisCache adapter with the Memory adapter and a TTL of 4800 seconds:
```ruby
- require 'flipper/adapters/memory'
require 'flipper/adapters/redis_cache'
redis = Redis.new(url: ENV['REDIS_URL'])
memory_adapter = Flipper::Adapters::Memory.new
adapter = Flipper::Adapters::RedisCache.new(memory_adapter, redis, 4800)
@@ -105,10 +101,9 @@
Example using the ActiveSupportCacheStore adapter with ActiveSupport's [MemoryStore](http://api.rubyonrails.org/classes/ActiveSupport/Cache/MemoryStore.html), Flipper's [Memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb), and a TTL of 5 minutes.
```ruby
require 'active_support/cache'
-require 'flipper/adapters/memory'
require 'flipper/adapters/active_support_cache_store'
memory_adapter = Flipper::Adapters::Memory.new
cache = ActiveSupport::Cache::MemoryStore.new
adapter = Flipper::Adapters::ActiveSupportCacheStore.new(memory_adapter, cache, expires_in: 5.minutes)