Ruby on rails 3 在何处初始化Dalli::Client
我刚刚开始使用Dalli gem进行内存缓存Ruby on rails 3 在何处初始化Dalli::Client,ruby-on-rails-3,memcached,dalli,Ruby On Rails 3,Memcached,Dalli,我刚刚开始使用Dalli gem进行内存缓存 我只是想知道,如果我想从缓存中获取一些数据,我是否需要在每个请求中创建一个Dalli::Client实例,或者我可以声明一个可以重用的单例?在您的配置/environments/production.rb中: config.cache\u store=:dalli\u storeconfig.cache\u store=:dalli\u store, 'cache-1.example.com',{:namespace=>RAILS\u应用程序的名称,
我只是想知道,如果我想从缓存中获取一些数据,我是否需要在每个请求中创建一个Dalli::Client实例,或者我可以声明一个可以重用的单例?在您的
配置/environments/production.rb中:
config.cache\u store=:dalli\u store
config.cache\u store=:dalli\u store,
'cache-1.example.com',{:namespace=>RAILS\u应用程序的名称,
:expires_in=>1.day,:compress=>true}