Adapters
Flipper is built on adapters for maximum flexibility. Regardless of what data store you are using, Flipper can performantly store data in it. Storage adapters are local to your application, so you'll have blazing fast feature checks that are always in sync and available, even if Flipper Cloud isn't for some reason.
Officially Supported
Pick one of our supported adapters and follow the installation instructions:
Adapter | Best for... |
---|---|
ActiveRecord | Production Rails Apps |
ActiveSupportCacheStore | Production Rails Apps with Aggressive Caching Needs |
Sequel | Production Ruby apps already using Sequel |
Redis | Production Ruby apps already using Redis |
Mongo | Production Ruby apps already using Mongo |
Moneta | Production Ruby apps already using Moneta to connect to a variety of key-value datastores |
PStore | When a local file is enough or you need something that works with multiple processes like some system tests |
Memory | Testing Environments |
HTTP | Connecting to Flipper::Api
|
Read-only | Preventing writes from a Production console |
Failsafe | Graceful failures when an exception is raised |
Rollout | Migrating from Rollout to Flipper |
JavaScript in Rails | While not a standard adapter, we've written a blog post with recommendations and examples of how to expose feature flags to client-side code in Rails apps. |
Create a new adapter
Don't see an adapter that suits your needs? You can create your own. We even provide automatic (rspec and minitest) tests for you, so you know you've built your custom adapter correctly.
Swapping Adapters
If you find yourself using one adapter and would like to swap to another, you can do that! Flipper adapters support importing another adapter's data. This will wipe the adapter you are wanting to swap to, if it isn't already clean, so please be careful.
# Say you are using redis...
redis_adapter = Flipper::Adapters::Redis.new(Redis.new)
redis_flipper = Flipper.new(redis_adapter)
# And redis has some stuff enabled...
redis_flipper.enable(:search)
redis_flipper.enable_percentage_of_time(:verbose_logging, 5)
redis_flipper.enable_percentage_of_actors(:new_feature, 5)
redis_flipper.enable_actor(:issues, Flipper::Actor.new('1'))
redis_flipper.enable_actor(:issues, Flipper::Actor.new('2'))
redis_flipper.enable_group(:request_tracing, :staff)
# And you would like to switch to active record...
ar_adapter = Flipper::Adapters::ActiveRecord.new
ar_flipper = Flipper.new(ar_adapter)
# NOTE: This wipes active record clean and copies features/gates from redis into active record.
ar_flipper.import(redis_flipper)
# active record is now identical to redis.
ar_flipper.features.each do |feature|
pp feature: feature.key, values: feature.gate_values
end