Created
March 14, 2023 20:32
-
-
Save bkeepers/3320e5bf518f352f2edfe32a3d1c775b to your computer and use it in GitHub Desktop.
Use Sync adapter to keep memory in sync with storage adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/flipper.rb | |
require 'flipper/adapters/sync' | |
Rails.application.configure do | |
# Disable per-request memoization | |
config.flipper.memoize = false | |
end | |
Flipper.configure do |config| | |
config.adapter do | |
# Primary storage adapter | |
storage_adapter = Flipper::Adapters::ActiveRecord.new | |
# Memory adapter for fast reads | |
memory_adapter = Flipper::Adapters::Memory.new | |
# Keep in sync in main thread on an interval | |
Flipper::Adapters::Sync.new(memory_adapter, storage_adapter, interval: 10) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bkeepers Does this require a specific branch, or can this be done with main?