小编典典

Rails Redis设置maxmemory和maxmemory-policy

redis

我正在尝试设置maxmemorymaxmemory-policy在我的Rails应用程序的我cache_store配置。

我在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的网络上看到任何示例,最近的事情是在使用rails缓存时使用rails处理redis
maxmemory情况,但是没有给出任何示例。

我还克隆并grepped用于maxmemory在该redis-rb宝石(https://github.com/redis/redis-
rb),但没有出现。因此,它似乎尚未实现。


阅读 498

收藏
2020-06-20

共1个答案

小编典典

如果您将缓存存储设置为使用redis-rb,并且尚未实现maxmemory,那么我看不出它为什么起作用。

特别是,似乎您在redis服务器的配置中配置了redis的maxmemory,所以我认为您不能通过连接的客户端(即redis-rb)来实现。

2020-06-20