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

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

问题描述

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



我认为他们有足够的差别来保证使用两者。然而,在heroku上,使用memcached和redis都有单独的费用。我使用memcached进行缓存是因为最近最少使用的密钥会自动从缓存中被移出,并且我将它们迁移到只使用redis?

我不需要缓存数据来坚持。 Redis对我来说基本上是陌生的,但我知道它默认是持久的,并且这些键不会自动从缓存中过期。



编辑:只想更清晰与我的问题。我知道只使用Redis而不是两者都是可行的。我想我只想知道这样做是否有任何特定的缺点?考虑到实施和基础设施,我有什么理由不应该只使用Redis? (也就是说,对于简单缓存,memcached的速度更快?)我还没有发现任何明确的方法。 解决方案

假设从memcached到你已经做的缓存的redis是很容易的,我会用redis去保持简单。

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


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.

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?

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.

EDIT: 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.

解决方案

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.

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天全站免登陆