twmills
twmills

Reputation: 3015

How to namespace caches by environment using config.cache_store = :redis_store?

I have set up Rails to use redis as its cache store:

config.cache_store = :redis_store

However, I have a staging environment on the same server as production and they both use the same redis instance.

How can I namespace the redis cache records by environment?

Upvotes: 6

Views: 2620

Answers (2)

user2780708
user2780708

Reputation:

Add to initializers/session_store.rb

YourApp::Application.config.session_store :redis_store, servers: { namespace: 'sessions' }

Upvotes: 3

mikdiet
mikdiet

Reputation: 10018

redis-store gem can accept namespace as the second parameter for session store. Maybe it also can accept namespace for cache store the same way?

Rails Configuration

Upvotes: 2

Related Questions