我正在尝试在我的 Rails 应用程序的 cache_store 配置中设置 maxmemory
和 maxmemory-policy
。
我在 production.rb 文件中做了以下操作:
redis_url = "redis://localhost:6379/0"
config.cache_store = :redis_store, redis_url, { :expires_in => 4.weeks ,
:namespace => 'rails-cache',
:maxmemory => '25gb',
'maxmemory-policy' => 'volatile-ttl'}
但是 maxmemory 并不能正常工作。当我执行 Rails.cache.methods
时,我没有得到任何关于 memory
或 max
的方法。
我在网络上没有看到任何 Rails 示例,最接近的是 handling redis maxmemory situations with rails when using rails caching但它没有给出任何示例。
我还在 redis-rb
gem ( https://github.com/redis/redis-rb ) 中克隆并搜索了 maxmemory
,但没有任何结果。所以好像还没有实现。
最佳答案
如果您将缓存存储设置为使用 redis-rb,并且它没有实现 maxmemory,我不明白它为什么会起作用。
特别是,您似乎在 redis 服务器的配置中配置了 redis 的 maxmemory,所以我认为您不能通过连接的客户端(即 redis-rb)来完成。
关于ruby-on-rails - Rails Redis 设置 maxmemory 和 maxmemory-policy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17537795/