本文介绍了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 和缓存,memcache 和redis 切换方便吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!