heroku / memcache和dalli的奇怪缓存问题

考虑以下。 从我的heroku控制台:

>> Rails.cache.stats => {"server_id"=>{"evictions"=>"0", "curr_items"=>"2064", "total_items"=>"18793", "bytes"=>"7674501", ... >> Rails.cache.clear => [true] >> Rails.cache.stats => {"server_id"=>{"evictions"=>"0", "curr_items"=>"2064", "total_items"=>"18793", "bytes"=>"7674501", 

超级怪异 – 如何清除我的缓存!!


类似问题? : https : //stackoverflow.com/q/7122513/192791

如果通过控制台直接连接到Dalli / memcahced客户端,则flush_all将清除缓存。

 dc = Dalli::Client.new('localhost:11211') dc.flush_all 

注意:统计信息需要一段时间才能更新,但缓存肯定会清除。

http://devcenter.heroku.com/articles/building-a-rails-3-application-with-the-memcache-addon上的Expiring Cache部分建议使用filter

 after_save :expire_contact_all_cache after_destroy :expire_contact_all_cache def expire_contact_all_cache Rails.cache.delete('Contact.all') end