Skip to content

Commit

Permalink
Use mem_cache_store instead of dalli_store
Browse files Browse the repository at this point in the history
`dalli_store` is deprecated since dalli 2.7.11.

We can now enable cache_versioning. We didn't enable it when upgrading
to Rails 5.2 because of possible incompatibility with `dalli_store` [1],
even though apparently some the issues were fixed in dalli 2.7.9 and
dalli 2.7.10 [2].

Since using cache versioning makes cache expiration more efficient, and
I'm not sure whether the options we were passing to the dalli store are
valid with memcache store (documentation here is a bit lacking), I'm
just removing the option we used to double the default cache size on
production.

[1] https://www.schneems.com/2018/10/17/cache-invalidation-complexity-rails-52-and-dalli-cache-store
[2] https://github.com/petergoldstein/dalli/blob/master/History.md
  • Loading branch information
javierm committed Aug 15, 2021
1 parent 1d594d1 commit 8c4e08a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class Application < Rails::Application
# Use local forms with `form_with`, so it works like `form_for`
config.action_view.form_with_generates_remote_forms = false

# Keep disabling cache versioning until we verify it's compatible
# with `:dalli_store` and with the way we cache stats
config.active_record.cache_versioning = false

# Keep using AES-256-CBC for message encryption in case it's used
# in any CONSUL installations
config.active_support.use_authenticated_message_encryption = false
Expand Down
2 changes: 1 addition & 1 deletion config/environments/preproduction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Use a different cache store in production.
config.cache_store = :dalli_store, { value_max_bytes: 2000000 }
config.cache_store = :mem_cache_store, { value_max_bytes: 2000000 }

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
config.log_tags = [:request_id]

# Use a different cache store in production.
config.cache_store = :dalli_store, { value_max_bytes: 2000000 }
config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
Expand Down
2 changes: 1 addition & 1 deletion config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Use a different cache store in production.
config.cache_store = :dalli_store
config.cache_store = :mem_cache_store

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
Expand Down

0 comments on commit 8c4e08a

Please sign in to comment.