2014-02-26 16 views
0

只是想知道爲什麼你必須設置緩存到控制檯工作到期? 顯然leaving it out,它不應該過期 - 但我不能得到它的工作?如果我沒有設置過期時間,則不會返回密鑰。只有在設置了到期時,Rails緩存才能正常工作?

1.9.3p392 :014 > Rails.cache.write "foo", "bar" 
1.9.3p392 :015 > Rails.cache.read "foo" 
=> nil 
1.9.3p392 :016 > 
1.9.3p392 :017 > Rails.cache.write "foo", "bar", :expires_in => 3.hours 
=> true 
1.9.3p392 :018 > 
1.9.3p392 :019 > Rails.cache.read "foo" 
=> "bar" 

回答

0

發現從cache_store配置中刪除「expires_at」取得了訣竅。我不需要設置過期時間,因爲memcache會在完成時清除最老的等等(按照俄羅斯娃娃緩存)。

config.cache_store = :dalli_store, '127.0.0.1:11211', { :namespace => 'blah', :expires_in => 3.months, :compress => true } 

成爲

config.cache_store = :dalli_store, '127.0.0.1:11211', { :namespace => 'blah', :compress => true } 
相關問題