简体   繁体   English

需要LRU缓存时,Memcached vs Redis为Rails.cache

[英]Memcached vs Redis as Rails.cache when requiring an LRU cache

I currently use Redis as a work queue for Sidekiq. 我目前使用Redis作为Sidekiq的工作队列。 I'm interested in also using it as a caching mechanism for Rails.cache. 我也有兴趣将它用作Rails.cache的缓存机制。

The recommended Rails caching mechanism never expires items and relies on evicting the least recently used (LRU) item. 推荐的Rails缓存机制永远不会使项目过期,并依赖于驱逐最近最少使用(LRU)的项目。 Unfortunately, Redis by default isn't configured to evict the least recently used item while the recommended cache store, memcached, is. 不幸的是,默认情况下,Redis不配置为驱逐最近最少使用的项目,而推荐的缓存存储是memcached。

Furthermore, evicting items isn't a behavior I would want for my work queue, and configuring the same Redis instance to do this could lead to undesirable results. 此外,驱逐项目不是我想要的工作队列行为,并且配置相同的Redis实例来执行此操作可能会导致不良结果。 Nor would I want my queue to share cycles with my cache anyways. 我也不希望我的队列与我的缓存共享周期。

What would you all recommend in this situation? 在这种情况下你会推荐什么? A second redis store to act as a cache and have LRU configured? 第二个redis存储充当缓存并配置了LRU? Or just use the rails recommended memcached cache store and only use redis alone to be a queue? 或者只使用rails推荐的memcached缓存存储并且仅使用redis作为队列?

I'm leaning towards using both Redis and Memcached, despite plenty of stack overflow articles recommending otherwise. 我倾向于使用Redis和Memcached,尽管有大量的堆栈溢出文章推荐否则。 memcached supporting LRU eviction by default is what wins me over. memcached默认支持LRU驱逐是赢得我的。

Some articles: 一些文章:

Hidden deeper in the comments, posters mention that memcached's LRU eviction as a great reason to use it as a cache. 在评论中隐藏得更深,海报提到memcached的LRU驱逐是将其用作缓存的一个很好的理由。

Ended up using both redis and memcached. 使用redis和memcached结束。 Pretty happy with the results. 对结果非常满意。

Main difference is that Memcached can run in parallel cores/machines but Redis is so lightweight and fast that it takes a good amount of load to get to its limit if it's running on a decent machine, where it only uses a couple cores, well since it works to use both for you that's great, but it sounds like a bit unnecessary complexity to use both, that's all. 主要区别在于Memcached可以在并行内核/机器上运行,但是Redis是如此轻量级和快速,如果它运行在一台不错的机器上,它只需要使用几个内核,它需要很大的负载才能达到极限。它可以同时用于你,但是听起来有点不必要的复杂性,这就是全部。 (ie if you need contractors to work on it etc you'll need someone with experience in both technologies rather than just one) (即如果你需要承包商来处理它等,你需要有这两种技术经验的人,而不仅仅是一个)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM