为什么使用Redis代替MongoDb进行缓存? [英] Why Use Redis instead of MongoDb for Caching?

查看:717
本文介绍了为什么使用Redis代替MongoDb进行缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我看到很多人使用Redis作为缓存,为什么不使用Mongo?据我所知,Redis可以在诸如memcache之类的索引上设置过期日期,但是是否有任何理由不使用Mongo?

I've seen many people using Redis as a cache lately, why not Mongo? As far as I could tell Redis can set an expire date on an index, like memcache but otherwise are there any reasons not to use Mongo for this?

我问,因为我在MySQL中进行大型联接,然后在选择数据后更改数据.我已经在网站的其他部分上使用了内存缓存,但是将其保存在Mongo中将使我能够对缓存的数据进行地理空间搜索.

I ask as I'm doing a large join in MySQL and then changing the data after selecting it. I'm already using memcache on other parts of the site but saving this in Mongo would allow me to do geospatial searches on the cached data.

推荐答案

许多人的确将MongoDB用于中低端缓存,并且效果很好.

A lot of people do use MongoDB for a low-medium grade cache and it works just great.

由于通过临时查询功能,它比简单的键值存储提供更多的功能,因此它不像Memcache或Redis那样纯净缓存层(插入和检索数据可能会更慢).

Because it offers more functionality than a simple key value store via ad-hoc queryability it isn't as pure of a caching layer as a memcache or redis (it can be slower to insert and retrieve data).

可以获得极高的性能(工作集毕竟在RAM中),但是数据模型更重.

Extremely high performance is attainable (the working set is in RAM after all), but the data model is heavier.

但是,另一方面,MongoDB确实提供了一个持久层,对于大多数开发人员来说,持久层对于大多数时间而言更有意义(与Redis不同).

However, on the flip side, MongoDB does offer a persistance layer that makes a lot more sense (to most developers) for the type of data that is most likely needed at a later time, unlike Redis.

这篇关于为什么使用Redis代替MongoDb进行缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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