Redis 和 Memcache 还是 Redis? [英] Redis and Memcache or just Redis?

查看:29
本文介绍了Redis 和 Memcache 还是 Redis?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过简单的 Rails.cache 界面在我的 Rails 3 应用程序中使用 memcached 进行一些缓存,现在我想使用 redis 和 resque 进行一些后台作业处理.

I'm using memcached for some caching in my Rails 3 app through the simple Rails.cache interface and now I'd like to do some background job processing with redis and resque.

我认为它们的不同足以保证同时使用两者.但是,在 heroku 上,使用 memcached 和 redis 需要支付单独的费用.两者都使用有意义还是我应该迁移到仅使用 redis?

I think they're different enough to warrant using both. On heroku though, there are separate fees to use both memcached and redis. Does it make sense to use both or should I migrate to just using redis?

我喜欢使用 memcached 进行缓存,因为最近最少使用的键会自动从缓存中推出,而且我不需要缓存数据持久化.Redis 对我来说大多是新的,但我知道它默认是持久的,并且密钥不会自动从缓存中过期.

I like using memcached for caching because least recently used keys automatically get pushed out of the cache and I don't need the cache data to persist. Redis is mostly new to me, but I understand that it's persistent by default and that keys do not expire out of the cache automatically.

只是想更清楚我的问题.我知道只使用 Redis 而不是两者都是可行的.我想我只是想知道这样做是否有任何特定的缺点?考虑到实现和基础设施,有什么理由我不应该只使用 Redis?(即,对于简单的缓存,memcached 是否更快?)我还没有找到任何明确的方法.

Just wanted to be more clear with my question. I know it's feasible to use only Redis instead of both. I guess I just want to know if there are any specific disadvantages in doing so? Considering both implementation and infrastructure, are there any reasons why I shouldn't just use Redis? (I.e., is memcached faster for simple caching?) I haven't found anything definitive either way.

推荐答案

假设从 memcached 迁移到 redis 来实现你已经做的缓存很容易,我会使用 redis 只是为了让事情变得简单.

Assuming that migrating from memcached to redis for the caching you already do is easy enough, I'd go with redis only to keep things simple.

在 redis 中,持久性是可选的,因此如果需要,您可以像使用 memcached 一样使用它.您甚至可能会发现,使缓存持久化对于避免重新启动后的大量缓存未命中很有用.到期也可用 - 该算法与 memcached 有点不同,但对于大多数用途来说还不够重要 - 请参阅 http://redis.io/commands/expire 了解详情.

In redis persistence is optional, so you can use it much like memcached if that is what you want. You may even find that making your cache persistent is useful to avoid lots of cache misses after a restart. Expiry is available also - the algorithm is a bit different from memcached, but not enough to matter for most purposes - see http://redis.io/commands/expire for details.

这篇关于Redis 和 Memcache 还是 Redis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆