我在我的应用中使用redis-cache进行片段缓存。当redis关闭或无法访问时,我会收到导致500错误的超时异常。
很少发生这种情况,但对于缓存,我希望rails将超时视为:
有什么建议吗?这是可以在rails缓存中配置的东西,还是我需要做一些猴子修补来优雅地处理这个案例?
我的stacktrace的相关部分在下面,以防它以任何方式帮助。 。
execution expired
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/timeout.rb:60:in `new'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/connection/ruby.rb:26:in `connect'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/connection/ruby.rb:128:in `with_timeout'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/connection/ruby.rb:25:in `connect'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:227:in `establish_connection'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:23:in `connect'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:247:in `ensure_connected'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:137:in `process'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:206:in `logging'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:136:in `process'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis/client.rb:46:in `call'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis.rb:157:in `get'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/monitor.rb:242:in `synchronize'
bundle/gems/ruby/1.8/gems/redis-2.2.2/lib/redis.rb:156:in `get'
bundle/gems/ruby/1.8/gems/redis-store-1.0.0.1/lib/redis/store/interface.rb:5:in `get'
bundle/gems/ruby/1.8/gems/redis-store-1.0.0.1/lib/redis/store/marshalling.rb:13:in `get'
bundle/gems/ruby/1.8/gems/redis-store-1.0.0.1/lib/active_support/cache/redis_store.rb:119:in `read_entry'
答案 0 :(得分:0)
凯文,
好奇,您使用的是什么Rails版本?
redis-store项目中的这个问题似乎与您遇到的问题有关:https://github.com/jodosha/redis-store/issues/56。该修复程序仅解决了Rails 3。
Rails 2的修复程序在这里:https://github.com/jodosha/redis-store/pull/83。查看redis-store 1.0.0.1的源代码,我没有看到包含该修复程序。