经过一些
研究,一个可能的解释是initialize_cache初始化程序是在rails /
initializers之前运行的。因此,如果未在执行链的早期定义它,则不会设置缓存存储区。您必须在链的早期配置它,例如在application.rb或environment
/ production.rb中
我的解决方案是在对应用进行如下配置之前移动APP_CONFIG加载:
APP_ConFIG = YAML.load_file(File.expand_path('../config.yml', __FILE__))[Rails.env]然后在同一个文件中:
config.cache_store = :redis_store, APP_CONFIG['redis']
另一个选择是将cache_store放在before_configuration块中,如下所示:
config.before_configuration do APP_ConFIG = YAML.load_file(File.expand_path('../config.yml', __FILE__))[Rails.env] config.cache_store = :redis_store, APP_CONFIG['redis']end


