Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails and caching, is it easy to switch between memcache and redis?

Is there a common api such that if I switch between Redis or Memcached I don't have to change my code, just a config setting?

like image 411
Blankman Avatar asked Nov 19 '10 03:11

Blankman


People also ask

Should I use memcache or Redis?

Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.

Does Rails cache use Redis?

Rails 5.2 introduced built-in Redis cache store, which allows you to store cache entries in Redis.

When should you choose Memcached over Redis?

Conclusion: Memcached was one of the first popular open source memory caching solutions and works well for basic key value workloads. However, if you are working in the enterprise, or are just looking for a more modern, feature rich and actively developed product, Redis is the best solution.

Why would you select a Memcached ElastiCache cluster over Redis?

With both ElastiCache for Redis and ElastiCache for Memcached you: No longer need to perform management tasks such as hardware provisioning, software patching, setup, configuration, and failure recovery. This allows you to focus on high value application development.


1 Answers

As long as you don't initialize the Memcached client yourself but you rely on Rails.cache common API, switching from Memcached to Redis is just a matter of installing redis-store and changing the configuration from

config.cache_store = :memcached_store 

to

config.cache_store = :redis_store 

More info about Rails.cache.

like image 104
Simone Carletti Avatar answered Sep 28 '22 08:09

Simone Carletti