Skip to content

Commit facb21a

Browse files
added support for REDIS_CACHE_URL
1 parent 339e261 commit facb21a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
SECRET_KEY_BASE=change-me-generate-with-bin-rails-secret
33
DATABASE_URL=postgres://postgres@localhost:5432/spree_production
44
REDIS_URL=redis://localhost:6379/0
5+
# REDIS_CACHE_URL=redis://localhost:6380/0 # dedicated cache Redis (falls back to REDIS_URL)
56

67
# Web Server
78
PORT=3000

config/environments/production.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@
5353
# Don't log any deprecations.
5454
config.active_support.report_deprecations = false
5555

56-
# Use Redis for caching if REDIS_URL is set, otherwise fall back to memory store.
57-
if ENV["REDIS_URL"].present?
58-
config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }
56+
# Use Redis for caching. REDIS_CACHE_URL allows a dedicated cache Redis,
57+
# falling back to REDIS_URL (shared with Sidekiq) if not set.
58+
redis_cache_url = ENV["REDIS_CACHE_URL"] || ENV["REDIS_URL"]
59+
if redis_cache_url.present?
60+
config.cache_store = :redis_cache_store, { url: redis_cache_url }
5961
else
6062
config.cache_store = :memory_store
6163
end

0 commit comments

Comments
 (0)