title: Using different redis stores for session and caching in Rails 5
body: <p>I am a newbie to Ruby and Rails. I am building a web application using Ruby on Rails 5.2. I have configured it to use the <code>redis-cache-store</code> to manage the view caching:</p>
  
  <pre><code>config.cache_store = :redis_cache_store, { driver: :hiredis, namespace: "my-app", compress: true, url: ENV["REDIS_URL"] }
  </code></pre>
  
  <p>And I have configured my session storage as:</p>
  
  <pre><code>Rails.application.config.session_store :cache_store, {
    key: "sid",
    expire_after: 30.minutes
  }
  </code></pre>
  
  <p>So here I am using the <code>:cache_store</code> as my session store. As far as I understand, this means the entries for the view cache and the session data are stored in the same Redis database.</p>
  
  <p>From what I understand, the <code>redis-rails</code> gem is no longer required if using Rails 5.2 as there is a built-in support for redis - <a href="https://github.com/redis-store/redis-rails#a-quick-note-about-rails-52" rel="nofollow noreferrer">https://github.com/redis-store/redis-rails#a-quick-note-about-rails-52</a>. Hence, I have not used that gem.</p>
  
  <p>Is there a way to use a different redis store for sessions and different one for view caching?</p>
  
  <p>Or am I trying to do something which is unusual in Rails-land?</p>