【问题标题】:Rails Redis setting maxmemory and maxmemory-policyRails Redis 设置 maxmemory 和 maxmemory-policy
【发布时间】:2013-07-06 10:39:22
【问题描述】:

我正在尝试在我的 Rails 应用程序的 cache_store 配置中设置 maxmemorymaxmemory-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 时,我没有得到任何关于memorymax 的方法。

我在网上没有看到 Rails 的任何示例,最接近的是 handling redis maxmemory situations with rails when using rails caching,但它没有给出任何示例。

我还在redis-rb gem (https://github.com/redis/redis-rb) 中克隆并搜索了maxmemory,但没有出现任何结果。所以好像还没有实现。

【问题讨论】:

    标签: ruby-on-rails ruby caching redis


    【解决方案1】:

    如果您将缓存存储设置为使用 redis-rb,并且它没有实现 maxmemory,我不明白它为什么会起作用。

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

    【讨论】:

    • 是的,在我提出问题后,我通读了他们的代码并意识到他们还没有实现 maxmemory 和 maxmemory-policy。在我问这个问题之前,我不是 100% 确定的。感谢您的回复。
    【解决方案2】:

    我相信您必须在 redis.conf(或您的 AWS 配置)中设置它http://redis.io/topics/lru-cache

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-21
      • 2021-06-05
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-17
      相关资源
      最近更新 更多