Flush memcached in Rails console

Rails 4 is using Dalli memcached. You can check here

Sometimes you will need to flush all Dalli memcached in Rails, in order to refresh the page for new update. You have several methods. However, I think using Rails console is one of the straight way to do this. It is simple, and safe because you can check the right memcache server.

$ rails c -e ENVIRONMENT

## check the right Dalli memcached server
Rails.cache.dalli 

## => #86400, :compress=>true}, @ring=nil>

## Clear the cache
Rails.cache.clear

Published by

Colin Dao

I am a hardworking Rubyist in Hanoi, Vietnam

Leave a comment