Skip to content

Commit d188e78

Browse files
committed
Alternate configuration for Redis
1 parent 0f970f4 commit d188e78

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

INSTALL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,19 @@ 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/0` and for the 1h cache
257+
`redis://localhost:6379/1/cache`.
258+
259+
You can override the configuration with the following environment variables:
260+
261+
- `REDIS_HOST` for the hostname or the IP of your Redis server
262+
- `REDIS_PORT` for the port (default TCP 6379)
263+
- `REDIS_URL` for the full address (like `redis://127.0.0.1:6379/0`)
264+
- `REDIS_CACHE_URL` for the cache full address (like `redis://127.0.0.1:6379/1/cache`)
265+
266+
Warning: the current configuration doesn't support authentication or TLS. Be
267+
careful with a remote Redis because everything will be exchange in plain text,
268+
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.has_value?("REDIS_CACHE_URL") ? ENV["REDIS_CACHE_URL"] : "redis://localhost:6379/1/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.has_value?("REDIS_CACHE_URL") ? ENV["REDIS_CACHE_URL"] : "redis://localhost:6379/1/cache", expires_in: 1.hour }
5757

5858
config.action_mailer.perform_caching = false
5959

0 commit comments

Comments
 (0)