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?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- Getting Redis Master address from Sentinel C#
- How to specify memcache server to Rack::Session::M
I hate to mess with your goals, but I would advise against using redis over memcached for generic rails caching.
I use redis and resque extensively in a large rails application and I thought it would be nice to consolidate caching, raw redis and resque into one. I ran into a few big issues:
Good luck with your project. I love redis AND memcached and use them in all my projects, but I let one do it's job as a kick-ass data structure server and let the other one kick ass at caching.
The neat parts of Redis include caching "list-based" things - pushing/popping things from this list as they happen in your app.
Rather than de-serializing a large value from memcached, editing it, then re-serializing it.
This would be done in ruby code in a custom filter, vs. the basic rails cache.
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 fromto
More info about Rails.cache.