From ca77968e550de81ddf7daf4aaea712f922e4668e Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 4 Mar 2025 08:46:20 -0500 Subject: [PATCH] Work around Rails' shard swapping lock in the Solid Cache config Because solid cache started using shard swapping when given a `database:` key in https://github.com/rails/solid_cache/pull/219, and Rails doesn't distinguish which database is being swapped and which was locked. Hopefully I can make a change upstream that will enable swap locking only for a specific databases. Until then, let's just use a slightly more verbose configuration to work around it. --- config/cache.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/config/cache.yml b/config/cache.yml index 253588727..4b41834ab 100644 --- a/config/cache.yml +++ b/config/cache.yml @@ -1,17 +1,22 @@ -default: &default +default_options: &default_options store_options: # Cap age of oldest cache entry to fulfill retention policies # max_age: <%= 60.days.to_i %> max_size: <%= 256.megabytes %> namespace: <%= Rails.env %> +default_connection: &default_connection + connects_to: + database: + writing: :cache + development: - database: cache - <<: *default + <<: *default_connection + <<: *default_options test: - <<: *default + <<: *default_options production: - database: cache - <<: *default + <<: *default_connection + <<: *default_options