flipper 0.21.0.rc1 → 0.22.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04567e721e7189ed3a5a28c91833caa438e89c8dc412708c1d5487ebcf43e09e
4
- data.tar.gz: c31948ae275a36a986352ae8d53e858d63e67590a1cae3831013530446008608
3
+ metadata.gz: 14514238ff1ea823df0cefeb2e1048816b86995d582e6c3dda037d36db344078
4
+ data.tar.gz: 285650a29a45623ed0468a08736621ccf88a6453eeadd8f42a29740a4a2955bc
5
5
  SHA512:
6
- metadata.gz: 30e3b27356e2a24948cb4136c59be5a7a0d0b21631102999affa01c3e969dc037e6ff524df3da4ffc0c39ecd8ffbbb1798bda4593fca21f33aeebefb0236caff
7
- data.tar.gz: 7cb046ca418ff31219b9d786cd22c0f81de6c37c9efc38a718e9ddcf2c97027de0d1a351ddeeae1a24adf1db081dcb364e0751f4d2881ef126e2a98ff0212b63
6
+ metadata.gz: 3af99a75cafb349025fd03a6c2bab4bb224f76acd2a0ac820bf6306ded28235b615fc0f891ce8d3df7612eca26d631fc7a51fb6ee738fdfdb614a561b121af04
7
+ data.tar.gz: bbaa9c0da5be73f4d1ab4ebc284919585878162e2c0151e346d77ad6909fddff7d0da7eff823ad29281d645e521d53e21f1de9184efda072e90e919d465a2c48
@@ -1,10 +1,8 @@
1
1
  name: CI
2
- on:
3
- push:
4
- branches: [master]
5
- pull_request:
2
+ on: [push, pull_request]
6
3
  jobs:
7
- build:
4
+ test:
5
+ name: Test on ruby ${{ matrix.ruby }} and rails ${{ matrix.rails }}
8
6
  runs-on: ubuntu-latest
9
7
  services:
10
8
  redis:
@@ -18,8 +16,8 @@ jobs:
18
16
  strategy:
19
17
  matrix:
20
18
  ruby: ['2.5', '2.6', '2.7']
19
+ rails: ['5.2', '6.0.0', '6.1.0']
21
20
  env:
22
- RAILS_VERSION: 6.0.0
23
21
  SQLITE3_VERSION: 1.4.1
24
22
  REDIS_URL: redis://localhost:6379/0
25
23
  CI: true
@@ -36,10 +34,10 @@ jobs:
36
34
  uses: actions/cache@v1
37
35
  with:
38
36
  path: vendor/bundle
39
- key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
37
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
40
38
  restore-keys: |
41
- ${{ runner.os }}-gem-
42
- - name: Set up Ruby
39
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
40
+ - name: Set up Ruby ${{ matrix.ruby }}
43
41
  uses: actions/setup-ruby@v1
44
42
  with:
45
43
  ruby-version: ${{ matrix.ruby }}
@@ -47,11 +45,9 @@ jobs:
47
45
  run: sudo apt-get -yqq install libpq-dev
48
46
  - name: Install bundler
49
47
  run: gem install bundler
50
- - name: Run bundler
51
- run: bundle install --jobs 4 --retry 3
52
- - name: Run Rake
53
- run: bundle exec rake
54
- - name: Run Examples
48
+ - name: Run Rake with Rails ${{ matrix.rails }}
55
49
  env:
56
- FLIPPER_CLOUD_TOKEN: ${{ secrets.FLIPPER_CLOUD_TOKEN }}
57
- run: script/examples
50
+ RAILS_VERSION: ${{ matrix.rails }}
51
+ run: |
52
+ bundle install --jobs 4 --retry 3
53
+ bundle exec rake
@@ -0,0 +1,56 @@
1
+ name: Examples
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ name: Test on ruby ${{ matrix.ruby }} and rails ${{ matrix.rails }}
6
+ runs-on: ubuntu-latest
7
+ services:
8
+ redis:
9
+ image: redis
10
+ ports: ['6379:6379']
11
+ options: >-
12
+ --health-cmd "redis-cli ping"
13
+ --health-interval 10s
14
+ --health-timeout 5s
15
+ --health-retries 5
16
+ strategy:
17
+ matrix:
18
+ ruby: ['2.5', '2.6', '2.7']
19
+ rails: ['5.2', '6.0.0', '6.1.0']
20
+ env:
21
+ SQLITE3_VERSION: 1.4.1
22
+ REDIS_URL: redis://localhost:6379/0
23
+ CI: true
24
+ steps:
25
+ - name: Setup memcached
26
+ uses: KeisukeYamashita/memcached-actions@v1
27
+ - name: Start MongoDB
28
+ uses: supercharge/mongodb-github-action@1.3.0
29
+ with:
30
+ mongodb-version: 4.0
31
+ - name: Check out repository code
32
+ uses: actions/checkout@v2
33
+ - name: Do some action caching
34
+ uses: actions/cache@v1
35
+ with:
36
+ path: vendor/bundle
37
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
38
+ restore-keys: |
39
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
40
+ - name: Set up Ruby ${{ matrix.ruby }}
41
+ uses: actions/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby }}
44
+ - name: Install libpq-dev
45
+ run: sudo apt-get -yqq install libpq-dev
46
+ - name: Install bundler
47
+ run: gem install bundler
48
+ - name: Bundle install with Rails ${{ matrix.rails }}
49
+ env:
50
+ RAILS_VERSION: ${{ matrix.rails }}
51
+ run: bundle install --jobs 4 --retry 3
52
+ - name: Run Examples with Rails ${{ matrix.rails }}
53
+ env:
54
+ FLIPPER_CLOUD_TOKEN: ${{ secrets.FLIPPER_CLOUD_TOKEN }}
55
+ RAILS_VERSION: ${{ matrix.rails }}
56
+ run: script/examples
data/Changelog.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 0.22.1
2
+
3
+ ## Additions/Changes
4
+
5
+ * Remove Octicons and replace with a pure CSS status circle (https://github.com/jnunemaker/flipper/pull/547)
6
+ * Rescue unique errors in AR and Sequel when setting value (https://github.com/jnunemaker/flipper/commit/87f5a98bce7baad7a27b75b5bce3256967769f27)
7
+ * Add a Content-Security-Policy to flipper-ui (https://github.com/jnunemaker/flipper/pull/552)
8
+ * Fix Synchronizer issue that occurs for ActiveRecord adapter (https://github.com/jnunemaker/flipper/pull/554)
9
+
10
+ ## 0.22.0
11
+
12
+ ## Additions/Changes
13
+
14
+ * Enable log subscriber by default in Rails (https://github.com/jnunemaker/flipper/pull/525)
15
+ * Remove memoizer from API and UI (https://github.com/jnunemaker/flipper/pull/527). If you are using the UI or API without configuring the default instance of Flipper, you'll need to enable memoization if you want it. For examples, see the examples/ui and examples/api directories.
16
+ * Fix SQL reserved word use in get_all for ActiveRecord and Sequel (https://github.com/jnunemaker/flipper/pull/536).
17
+ * Handle spaces in names gracefully in UI (https://github.com/jnunemaker/flipper/pull/541).
18
+
1
19
  ## 0.21.0
2
20
 
3
21
  ### Additions/Changes
@@ -7,6 +25,41 @@
7
25
  * Added cloud recommendation to flipper-ui. Can be disabled with `Flipper::UI.configure { |config| config.cloud_recommendation = false }`. Just want to raise awareness that more is available if people want it (https://github.com/jnunemaker/flipper/pull/504)
8
26
  * Added default `flipper_id` implementation via `Flipper::Identifier` and automatically included it in ActiveRecord and Sequel models (https://github.com/jnunemaker/flipper/pull/505)
9
27
  * Deprecate superflous sync_method setting (https://github.com/jnunemaker/flipper/pull/511)
28
+ * Flipper is now pre-configured when used with Rails. By default, it will [memoize and preload all features for each request](docs/Optimization.md#memoization). (https://github.com/jnunemaker/flipper/pull/506)
29
+
30
+ ### Upgrading
31
+
32
+ You should be able to upgrade to 0.21 without any breaking changes. However, if you want to simplify your setup, you can remove some configuration that is now handled automatically:
33
+
34
+ 1. Adapters are configured when on require, so unless you are using caching or other customizations, you can remove adapter configuration.
35
+
36
+ ```diff
37
+ # config/initializers/flipper.rb
38
+ - Flipper.configure do |config|
39
+ - config.default { Flipper.new(Flipper::Adapters::ActiveRecord.new) }
40
+ - end
41
+ ```
42
+
43
+ 2. `Flipper::Middleware::Memoizer` will be enabled by default.
44
+
45
+ ```diff
46
+ # config/initializers/flipper.rb
47
+ - Rails.configuration.middleware.use Flipper::Middleware::Memoizer,
48
+ - preload: [:stats, :search, :some_feature]
49
+ + Rails.application.configure do
50
+ + # Uncomment to configure which features to preload on all requests
51
+ + # config.flipper.preload = [:stats, :search, :some_feature]
52
+ + end
53
+ ```
54
+
55
+ 3. `#flipper_id`, which is used to enable features for specific actors, is now defined by [Flipper::Identifier](lib/flipper/identifier.rb) on all ActiveRecord and Sequel models. You can remove your implementation if it is in the form of `ModelName;id`.
56
+
57
+ 4. When using `flipper-cloud`, The `Flipper::Cloud.app` webhook receiver is now mounted at `/_flipper` by default.
58
+
59
+ ```diff
60
+ # config/routes.rb
61
+ - mount Flipper::Cloud.app, at: "/_flipper"
62
+ ```
10
63
 
11
64
  ## 0.20.4
12
65
 
@@ -14,6 +67,7 @@
14
67
 
15
68
  * Allow actors and time gates to deal with decimal percentages (https://github.com/jnunemaker/flipper/pull/492)
16
69
  * Change Flipper::Cloud::Middleware to receive webhooks at / in addition to /webhooks.
70
+ * Add `write_through` option to ActiveSupportCacheStore adapter to support write-through caching (https://github.com/jnunemaker/flipper/pull/512)
17
71
 
18
72
  ## 0.20.3
19
73
 
data/Gemfile CHANGED
@@ -19,6 +19,7 @@ gem 'minitest-documentation'
19
19
  gem 'webmock', '~> 3.0'
20
20
  gem 'climate_control'
21
21
  gem 'redis-namespace'
22
+ gem 'webrick'
22
23
 
23
24
  group(:guard) do
24
25
  gem 'guard', '~> 2.15'
data/README.md CHANGED
@@ -21,7 +21,7 @@ Add this line to your application's Gemfile:
21
21
 
22
22
  You'll also want to pick a storage [adapter](#adapters), for example:
23
23
 
24
- gem 'flipper-active_record'`
24
+ gem 'flipper-active_record'
25
25
 
26
26
  And then execute:
27
27
 
@@ -157,6 +157,7 @@ A few miscellaneous docs with more info for the hungry.
157
157
  | pic | @mention | area |
158
158
  |---|---|---|
159
159
  | ![@jnunemaker](https://avatars3.githubusercontent.com/u/235?s=64) | [@jnunemaker](https://github.com/jnunemaker) | most things |
160
+ | ![@bkeepers](https://avatars3.githubusercontent.com/u/173?s=64) | [@bkeepers](https://github.com/bkeepers) | most things |
160
161
  | ![@alexwheeler](https://avatars3.githubusercontent.com/u/3260042?s=64) | [@alexwheeler](https://github.com/alexwheeler) | api |
161
162
  | ![@thetimbanks](https://avatars1.githubusercontent.com/u/471801?s=64) | [@thetimbanks](https://github.com/thetimbanks) | ui |
162
163
  | ![@lazebny](https://avatars1.githubusercontent.com/u/6276766?s=64) | [@lazebny](https://github.com/lazebny) | docker |
data/docker-compose.yml CHANGED
@@ -1,34 +1,37 @@
1
- # postgres:
2
- # container_name: flipper_postgres
3
- # image: postgres:9.4
4
- redis:
5
- container_name: flipper_redis
6
- image: redis:2.8
7
- mongo:
8
- container_name: flipper_mongo
9
- image: mongo:3.3
10
- memcached:
11
- container_name: flipper_memcached
12
- image: memcached:1.4.33
13
- app:
14
- container_name: flipper_app
15
- build: .
16
- dockerfile: Dockerfile
17
- volumes:
18
- - .:/srv/app
19
- volumes_from:
20
- - bundle_cache
21
- links:
22
- # - postgres
23
- - redis
24
- - mongo
25
- - memcached
26
- environment:
27
- - REDIS_URL=redis://redis:6379
28
- - MONGODB_HOST=mongo
29
- - MEMCACHED_URL=memcached:11211
30
- bundle_cache:
31
- container_name: flipper_bundle_cache
32
- image: busybox
33
- volumes:
34
- - /bundle_cache
1
+ version: "2.4"
2
+ services:
3
+ # postgres:
4
+ # container_name: flipper_postgres
5
+ # image: postgres:9.4
6
+ redis:
7
+ container_name: flipper_redis
8
+ image: redis:6.2.5
9
+ mongo:
10
+ container_name: flipper_mongo
11
+ image: mongo:4.4.8
12
+ memcached:
13
+ container_name: flipper_memcached
14
+ image: memcached:1.4.33
15
+ app:
16
+ container_name: flipper_app
17
+ build:
18
+ context: .
19
+ dockerfile: Dockerfile
20
+ volumes:
21
+ - .:/srv/app
22
+ volumes_from:
23
+ - bundle_cache
24
+ links:
25
+ # - postgres
26
+ - redis
27
+ - mongo
28
+ - memcached
29
+ environment:
30
+ - REDIS_URL=redis://redis:6379
31
+ - MONGODB_HOST=mongo
32
+ - MEMCACHED_URL=memcached:11211
33
+ bundle_cache:
34
+ container_name: flipper_bundle_cache
35
+ image: busybox
36
+ volumes:
37
+ - /bundle_cache
data/docs/Adapters.md CHANGED
@@ -4,18 +4,17 @@ I plan on supporting the adapters in the flipper repo. Other adapters are welcom
4
4
 
5
5
  ## Officially Supported
6
6
 
7
- * [ActiveRecord adapter](https://github.com/jnunemaker/flipper/blob/master/docs/active_record) - Rails 3, 4, 5, and 6.
8
- * [ActiveSupportCacheStore adapter](https://github.com/jnunemaker/flipper/blob/master/docs/active_support_cache_store) - ActiveSupport::Cache::Store
9
- * [Cassanity adapter](https://github.com/jnunemaker/flipper-cassanity)
10
- * [Http adapter](https://github.com/jnunemaker/flipper/blob/master/docs/http)
11
- * [memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb) – great for tests
12
- * [Moneta adapter](https://github.com/jnunemaker/flipper/blob/master/docs/moneta)
7
+ * [ActiveRecord adapter](https://github.com/jnunemaker/flipper/blob/master/docs/active_record) - Rails 5 and 6.
8
+ * [Sequel adapter](https://github.com/jnunemaker/flipper/blob/master/docs/sequel)
9
+ * [Redis adapter](https://github.com/jnunemaker/flipper/blob/master/docs/redis)
13
10
  * [Mongo adapter](https://github.com/jnunemaker/flipper/blob/master/docs/mongo)
14
11
  * [PStore adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/pstore.rb) – great for when a local file is enough
15
- * [read-only adapter](https://github.com/jnunemaker/flipper/blob/master/docs/read-only)
16
- * [Redis adapter](https://github.com/jnunemaker/flipper/blob/master/docs/redis)
17
- * [Rollout adapter](rollout/README.md)
18
- * [Sequel adapter](https://github.com/jnunemaker/flipper/blob/master/docs/sequel)
12
+ * [Http adapter](https://github.com/jnunemaker/flipper/blob/master/docs/http) - great for using with `Flipper::Api`
13
+ * [Moneta adapter](https://github.com/jnunemaker/flipper/blob/master/docs/moneta) - great for a variety of data stores
14
+ * [ActiveSupportCacheStore adapter](https://github.com/jnunemaker/flipper/blob/master/docs/active_support_cache_store) - great for Rails caching
15
+ * [Memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb) – great for tests
16
+ * [Read-only adapter](https://github.com/jnunemaker/flipper/blob/master/docs/read-only) - great for preventing writes from production console
17
+ * [Rollout adapter](rollout/README.md) - great for switching from rollout to flipper
19
18
 
20
19
  ## Community Supported
21
20
 
data/docs/Caveats.md CHANGED
@@ -1,4 +1,4 @@
1
1
  # Caveats
2
2
 
3
- 1. The [individual actor gate](https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md#2-individual-actor) is typically not designed for hundreds or thousands of actors to be enabled. This is an explicit choice to make it easier to batch load data from the adapters instead of performing individual checks for actors over and over. If you need to enable something for more than 20 individual people, I would recommend using a [group](https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md#5-group).
4
- 2. The disable method exists only to clear something that is enabled. If the thing you are disabling is not enabled, the disable is pointless. This means that if you enable one group an actor is in and disable another group, the feature will be enabled for the actor. ([related issue](https://github.com/jnunemaker/flipper/issues/71))
3
+ 1. The [individual actor gate](https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md#2-individual-actor) is typically not designed for hundreds or thousands of actors to be enabled. This is an explicit choice to make it easier to batch load data from the adapters instead of performing individual checks for actors over and over. If you need to enable something for more than 100 individual actors, I would recommend using a [group](https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md#5-group).
4
+ 2. The `disable` method exists only to clear something that is enabled. If the thing you are disabling is not enabled, the disable is pointless. This means that if you enable one group an actor is in and disable another group, the feature will be enabled for the actor. ([related issue](https://github.com/jnunemaker/flipper/issues/71))
data/docs/Optimization.md CHANGED
@@ -1,52 +1,63 @@
1
1
  # Optimization
2
2
 
3
- ## Memoizing Middleware
3
+ ## Memoization
4
4
 
5
- One optimization that flipper provides is a memoizing middleware. The memoizing middleware ensures that you only make one adapter call per feature per request. This means if you check the same feature over and over, it will only make one Mongo, Redis, or whatever call per feature for the length of the request.
5
+ By default, Flipper will preload and memoize all features to ensure one adapter call per request. This means no matter how many times you check features, Flipper will only make one network request to Postgres, MySQL, Redis, Mongo or whatever adapter you are using for the length of the request.
6
6
 
7
- You can use the middleware like so for Rails:
7
+ ### Preloading
8
+
9
+ Flipper will preload all features before each request by default, which is recommended if you have a limited number of features (< 100?) and they are used on most requests. If you have a lot of features, but only a few are used on most requests, you may want to customize preloading:
8
10
 
9
11
  ```ruby
10
- # setup default instance (perhaps in config/initializers/flipper.rb)
11
- Flipper.configure do |config|
12
- config.default do
13
- Flipper.new(...)
14
- end
12
+ # config/initializers/flipper.rb
13
+ Rails.application.configure do
14
+ # Load specific features that are used on most requests
15
+ config.flipper.preload = [:stats, :search, :some_feature]
16
+
17
+ # Or completely disable preloading
18
+ config.flipper.preload = false
15
19
  end
20
+ ```
21
+
22
+ Features that are not preloaded are still memoized, ensuring one adapter call per feature during a request.
23
+
24
+ ### Skip memoization
25
+
26
+ Prevent preloading and memoization on specific requests by setting `memoize` to a proc that evaluates to false.
16
27
 
17
- # This assumes you setup a default flipper instance using configure.
18
- Rails.configuration.middleware.use Flipper::Middleware::Memoizer
28
+ ```ruby
29
+ # config/initializers/flipper.rb
30
+ Rails.application.configure do
31
+ config.flipper.memoize = ->(request) { !request.path.start_with?("/assets") }
32
+ end
19
33
  ```
20
34
 
21
- **Note**: Be sure that the middleware is high enough up in your stack that all feature checks are wrapped.
35
+ ### Disable memoization
22
36
 
23
- **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`:
37
+ To disable memoization entirely:
24
38
 
25
39
  ```ruby
26
- Rails.configuration.middleware.use Flipper::Middleware::SetupEnv, -> { Flipper.new(...) }
27
- Rails.configuration.middleware.use Flipper::Middleware::Memoizer
40
+ Rails.application.configure do
41
+ config.flipper.memoize = false
42
+ end
28
43
  ```
29
44
 
30
- ### Options
31
-
32
- The Memoizer middleware also supports a few options. Use either `preload` or `preload_all`, not both.
33
-
34
- * **`:preload`** - An `Array` of feature names (`Symbol`) to preload for every request. Useful if you have features that are used on every endpoint. `preload` uses `Adapter#get_multi` to attempt to load the features in one network call instead of N+1 network calls.
35
- ```ruby
36
- Rails.configuration.middleware.use Flipper::Middleware::Memoizer,
37
- preload: [:stats, :search, :some_feature]
38
- ```
39
- * **`:preload_all`** - A Boolean value (default: false) of whether or not all features should be preloaded. Using this results in a `preload_all` call with the result of `Adapter#get_all`. Any subsequent feature checks will be memoized and perform no network calls. I wouldn't recommend using this unless you have few features (< 100?) and nearly all of them are used on every request.
40
- ```ruby
41
- Rails.configuration.middleware.use Flipper::Middleware::Memoizer,
42
- preload_all: true
43
- ```
44
- * **`:unless`** - A block that prevents preloading and memoization if it evaluates to true.
45
- ```ruby
46
- # skip preloading and memoizing if path starts with /assets
47
- Rails.configuration.middleware.use Flipper::Middleware::Memoizer,
48
- unless: ->(request) { request.path.start_with?("/assets") }
49
- ```
45
+ ### Advanced
46
+
47
+ Memoization is implemented as a Rack middleware, which can be used manually in any Ruby app:
48
+
49
+ ```ruby
50
+ use Flipper::Middleware::Memoizer,
51
+ preload: true,
52
+ unless: ->(request) { request.path.start_with?("/assets") }
53
+ ```
54
+
55
+ **Also Note**: If you need to customize the instance of Flipper used by the memoizer, you can pass the instance to `SetupEnv`:
56
+
57
+ ```ruby
58
+ use Flipper::Middleware::SetupEnv, -> { Flipper.new(...) }
59
+ use Flipper::Middleware::Memoizer
60
+ ```
50
61
 
51
62
  ## Cache Adapters
52
63
 
@@ -61,11 +72,15 @@ https://github.com/petergoldstein/dalli
61
72
  Example using the Dalli cache adapter with the Memory adapter and a TTL of 600 seconds:
62
73
 
63
74
  ```ruby
64
- dalli_client = Dalli::Client.new('localhost:11211')
65
- memory_adapter = Flipper::Adapters::Memory.new
66
- adapter = Flipper::Adapters::Dalli.new(memory_adapter, dalli_client, 600)
67
- flipper = Flipper.new(adapter)
75
+ Flipper.configure do |config|
76
+ config.adapter do
77
+ dalli = Dalli::Client.new('localhost:11211')
78
+ adapter = Flipper::Adapters::Memory.new
79
+ Flipper::Adapters::Dalli.new(adapter, dalli, 600)
80
+ end
81
+ end
68
82
  ```
83
+
69
84
  ### RedisCache
70
85
 
71
86
  Applications using [Redis](https://redis.io/) via the [redis-rb](https://github.com/redis/redis-rb) client can take advantage of the RedisCache adapter.
@@ -75,12 +90,15 @@ Initialize `RedisCache` with a flipper [adapter](https://github.com/jnunemaker/
75
90
  Example using the RedisCache adapter with the Memory adapter and a TTL of 4800 seconds:
76
91
 
77
92
  ```ruby
78
- require 'flipper/adapters/redis_cache'
93
+ require 'flipper/adapters/redis_cache'
79
94
 
80
- redis = Redis.new(url: ENV['REDIS_URL'])
81
- memory_adapter = Flipper::Adapters::Memory.new
82
- adapter = Flipper::Adapters::RedisCache.new(memory_adapter, redis, 4800)
83
- flipper = Flipper.new(adapter)
95
+ Flipper.configure do |config|
96
+ config.adapter do
97
+ redis = Redis.new(url: ENV['REDIS_URL'])
98
+ memory_adapter = Flipper::Adapters::Memory.new
99
+ Flipper::Adapters::RedisCache.new(memory_adapter, redis, 4800)
100
+ end
101
+ end
84
102
  ```
85
103
 
86
104
  ### ActiveSupportCacheStore
@@ -105,10 +123,15 @@ Example using the ActiveSupportCacheStore adapter with ActiveSupport's [MemorySt
105
123
  require 'active_support/cache'
106
124
  require 'flipper/adapters/active_support_cache_store'
107
125
 
108
- memory_adapter = Flipper::Adapters::Memory.new
109
- cache = ActiveSupport::Cache::MemoryStore.new
110
- adapter = Flipper::Adapters::ActiveSupportCacheStore.new(memory_adapter, cache, expires_in: 5.minutes)
111
- flipper = Flipper.new(adapter)
126
+ Flipper.configure do |config|
127
+ config.adapter do
128
+ Flipper::Adapters::ActiveSupportCacheStore.new(
129
+ Flipper::Adapters::Memory.new,
130
+ ActiveSupport::Cache::MemoryStore.new # Or Rails.cache,
131
+ expires_in: 5.minutes
132
+ )
133
+ end
134
+ end
112
135
  ```
113
136
 
114
137
  Setting `expires_in` is optional and will set an expiration time on Flipper cache keys. If specified, all flipper keys will use this `expires_in` over the `expires_in` passed to your ActiveSupport cache constructor.