2011-10-12 60 views

回答

2

你必須與:unless_exist選項寫:

Rails.cache.write(k, v, :unless_exist => true) 

該方法將返回只有當鑰匙不存在真實的。否則,該方法返回false:

if Rails.cache.write(k, v, :unless_exist => true) 
    # do something only when the key wasn't there 
end 
相關問題