【发布时间】:2019-01-14 00:25:19
【问题描述】:
我是 Ruby 和 Rails 的新手。我正在使用 Ruby on Rails 5.2 构建一个 Web 应用程序。我已将其配置为使用redis-cache-store 来管理视图缓存:
config.cache_store = :redis_cache_store, { driver: :hiredis, namespace: "my-app", compress: true, url: ENV["REDIS_URL"] }
我已将会话存储配置为:
Rails.application.config.session_store :cache_store, {
key: "sid",
expire_after: 30.minutes
}
所以我在这里使用:cache_store 作为我的会话存储。据我了解,这意味着视图缓存和会话数据的条目存储在同一个 Redis 数据库中。
据我了解,如果使用 Rails 5.2,则不再需要 redis-rails gem,因为它内置了对 redis 的支持 - https://github.com/redis-store/redis-rails#a-quick-note-about-rails-52。因此,我没有使用过那个宝石。
有没有办法为会话使用不同的 redis 存储并为视图缓存使用不同的存储?
或者我是否正在尝试做一些在 Rails-land 中不寻常的事情?
【问题讨论】:
标签: ruby-on-rails ruby redis ruby-on-rails-5