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运行并清除日敏感的缓存项目,但我更倾向于使用本机缓存过期。
任何想法?谢谢!