2
我想設置一個緩存系統,使用帶有Rails 3.1的Memcached插件和Heroku雪松堆棧上的dalli,以及應該在每天結束時過期的一些項目。Memcached:expires_in在Heroku的片段緩存
對於這個我使用一個實用方法:
def self.seconds_to_next_day
((DateTime.now.end_of_day - DateTime.now) * 24 * 60 * 60).to_i.seconds
end
和緩存像這樣在HAML觀點:
- cache "user_#{current_user.id}_my_groups", :expires_in => Utils.seconds_to_next_day do
= render "shared/my_groups"
但因爲它應該它不是在每一天結束時到期。我也試過秒數作爲一個整數,沒有。秒,但它沒有區別。
現在我已經回到了計劃任務,每天在00:00運行並清除日敏感的緩存項目,但我更傾向於使用本機緩存過期。
任何想法?謝謝!