Skip to content

Commit 8f2da36

Browse files
committed
Alternate configuration for Redis
1 parent cf0797e commit 8f2da36

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

INSTALL.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,17 @@ To be able to create your first news, you will need to add sections with link
250250

251251
Be sure to set title `LinuxFr.org` to one of your sections, otherwise you won't
252252
be able to create news in the redaction space.
253+
254+
## Alternative Redis configuration
255+
256+
Default Redis configuration is `redis://localhost:6379`, with database 0 for data
257+
and database 1 for the cache.
258+
259+
You can override the configuration with the following environment variables:
260+
261+
- `REDIS_URL` for the full address (like `redis://127.0.0.1:6379/0`)
262+
- `REDIS_CACHE_URL` for the cache full address (like `redis://127.0.0.1:6379/1`)
263+
264+
Warning: the current configuration doesn't support authentication or TLS. Be
265+
careful with a remote Redis because everything will be exchange in plain text,
266+
and you exposed your Redis server on the network.

config/environments/alpha.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
config.log_tags = [ :request_id ]
5454

5555
# Use a different cache store in production.
56-
config.cache_store = :redis_cache_store, { url: "redis://localhost:6379/1/cache", expires_in: 1.hour }
56+
config.cache_store = :redis_cache_store, { url: ENV.fetch("REDIS_CACHE_URL", "redis://localhost:6379/1"), namespace: "cache", expires_in: 1.hour }
5757

5858
config.action_mailer.perform_caching = false
5959

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
config.log_tags = [ :request_id ]
5454

5555
# Use a different cache store in production.
56-
config.cache_store = :redis_cache_store, { url: "redis://localhost:6379/1/cache", expires_in: 1.hour }
56+
config.cache_store = :redis_cache_store, { url: ENV.fetch("REDIS_CACHE_URL", "redis://localhost:6379/1"), namespace: "cache", expires_in: 1.hour }
5757

5858
config.action_mailer.perform_caching = false
5959

0 commit comments

Comments
 (0)