Weird cacheing issues with heroku / memcache and d

2019-05-02 13:24发布

Consider the following. From my heroku console:

>> 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",

Super weird -- how can I clear my cache!!


Similar Issue ? : https://stackoverflow.com/q/7122513/192791

2条回答
萌系小妹纸
2楼-- · 2019-05-02 13:56

The Expiring Cache section at http://devcenter.heroku.com/articles/building-a-rails-3-application-with-the-memcache-addon suggests using filters

after_save    :expire_contact_all_cache
after_destroy :expire_contact_all_cache

def expire_contact_all_cache
  Rails.cache.delete('Contact.all')
end
查看更多
Juvenile、少年°
3楼-- · 2019-05-02 13:58

If you connect directly to the Dalli/memcahced client through the console and flush_all the cache clears.

i.e.

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

NOTE: the stats take a while to update, but the cache will definitely clear.

查看更多
登录 后发表回答