Rails和缓存,是否容易在Memcache和Redis之间切换? [英] Rails and caching, is it easy to switch between memcache and redis?

查看:90
本文介绍了Rails和缓存,是否容易在Memcache和Redis之间切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个通用的api,这样,如果我在Redis或Memcached之间切换,就不必更改代码,而只需更改配置设置?

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?

推荐答案

只要您自己不初始化Memcached客户端,而是依靠Rails.cache通用API,从Memcached切换到Redis只是安装的问题 redis-store 并从以下位置更改配置

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

config.cache_store = :redis_store

更多有关Rails.cache的信息.

这篇关于Rails和缓存,是否容易在Memcache和Redis之间切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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