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

后端 未结 3 474
礼貌的吻别
礼貌的吻别 2020-12-13 00:41

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?

3条回答
  •  抹茶落季
    2020-12-13 01:41

    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.

提交回复
热议问题