2015-05-20 58 views
-1

我隨機得到以下錯誤消息。有沒有人有任何想法可能導致這種情況?來自Redis的NoMethodError(未定義方法`slice!'爲nil:NilClass)調用

unless (val = @cache.read(key)).nil? 
    return val 
    end 

其中@cache = Rails.cache

UPDATE

我使用這種寶石與此SSL plugin,所以錯誤:

NoMethodError (undefined method `slice!' for nil:NilClass): 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:274:in `read' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:248:in `block in read' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:236:in `io' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:247:in `read' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:112:in `block in call' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:217:in `block (2 levels) in process' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:353:in `ensure_connected' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:206:in `process' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:112:in `call' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:789:in `block in get' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize' 
/usr/local/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize' 
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:788:in `get' 
vendor/bundle/ruby/2.1.0/gems/redis-store-1.1.4/lib/redis/store/interface.rb:5:in `get' 
vendor/bundle/ruby/2.1.0/gems/redis-store-1.1.4/lib/redis/store/marshalling.rb:17:in `get' 
vendor/bundle/ruby/2.1.0/gems/redis-activesupport-4.0.0/lib/active_support/cache/redis_store.rb:169:in `read_entry' 
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/cache.rb:312:in `block in read' 
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/cache.rb:548:in `instrument' 
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/cache.rb:311:in `read' 
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/store.rb:34:in `get' 
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/scoped_store.rb:13:in `fetch' 
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/preferable_class_methods.rb:13:in `block in preference' 
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/preferable.rb:43:in `get_preference' 
vendor/bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/lib/spree/core/controller_helpers/ssl.rb:8:in `block (2 levels) in <module:SSL>' 

last place狂歡呼籲Redis的-RB之前打可能與插件有關。

line = @sock.getsnil時發生錯誤。在此之後,當地人確定是真實的。

[1] pry(#<Redis::Connection::Ruby>)> line 
=> nil 
[2] pry(#<Redis::Connection::Ruby>)> @sock 
=> #<OpenSSL::SSL::SSLSocket:0x007fdab2688730 
@callback_state=nil, 
@context= 
    #<OpenSSL::SSL::SSLContext:0x007fdab2688758 
    @ca_file=nil, 
    @ca_path=nil, 
    @cert=nil, 
    @cert_store=nil, 
    @client_ca=nil, 
    @client_cert_cb=nil, 
    @extra_chain_cert=nil, 
    @key=nil, 
    @npn_protocols=nil, 
    @npn_select_cb=nil, 
    @options=nil, 
    @renegotiation_cb=nil, 
    @servername_cb=nil, 
    @session_get_cb=nil, 
    @session_id_context=nil, 
    @session_new_cb=nil, 
    @session_remove_cb=nil, 
    @timeout=nil, 
    @tmp_dh_callback=nil, 
    @verify_callback=nil, 
    @verify_depth=nil, 
    @verify_mode=nil>, 
@eof=true, 
@hostname=nil, 
@io=#<Redis::Connection::TCPSocket:fd 11>, 
@rbuffer="", 
@sync=true, 
@sync_close=false, 
@wbuffer=""> 
[3] pry(#<Redis::Connection::Ruby>)> @sock.closed? 
=> false 

回答

相關問題