本文介绍了Rails Redis设置maxmemory和maxmemory-policy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的Rails应用程序的cache_store配置中设置 maxmemory maxmemory-policy 。 / p>

我在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 时,我没有任何关于内存的方法max



我在Rails的网络上看不到任何示例,最近的是,但未给出任何示例。



我还克隆了并复制了 redis-rb 中的 maxmemory 。 code> gem( ),但没有任何反应。

解决方案

如果您将缓存存储区设置为使用redis-rb,并且它没有



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


I'm trying to set maxmemory and maxmemory-policy in my cache_store configuration of my Rails app.

I did the following in my production.rb file:

  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'}

But the maxmemory doesn't seam to be working. When I do Rails.cache.methods I don't get any methods about memory or max.

I dont' see any examples on the web for Rails, the closest thing was handling redis maxmemory situations with rails when using rails caching but it doesn't give any examples.

I also cloned and grepped for maxmemory in the the redis-rb gem (https://github.com/redis/redis-rb), but nothing comes up. So it seem like it has not been implemented.

解决方案

If you set the cache store to use redis-rb, and it hasn't implemented maxmemory, I don't see why it'd work.

In particular, it seems like you configure redis's maxmemory in the redis server's config, so I don't think you can do it through a connecting client (ie. redis-rb).

这篇关于Rails Redis设置maxmemory和maxmemory-policy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:53