# How to invalidate the model caching in ruby?

**URL:** <https://www.ruby-forum.com/t/how-to-invalidate-the-model-caching-in-ruby/161078>\
**Category:** Rails\
**Created:** [February 23, 2009, 8:38am UTC](https://www.ruby-forum.com/t/how-to-invalidate-the-model-caching-in-ruby/161078 "2009-02-23T08:38:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [February 23, 2009, 8:38am UTC](https://www.ruby-forum.com/t/how-to-invalidate-the-model-caching-in-ruby/161078/1 "2009-02-23T08:38:56Z")

</div>

Hello All,

I used rails caching to cache the model as in model language.rb file

def self.cached\_languages  
return Rails.cache.fetch(‘languages’) { Language.all }  
end

Now I want to add/delete some new language to database. So when the  
table “languages” changes it should reflect in view. For that I want to  
invalidate the cache.

please tell me How i do that?

Thanks,

Vikas.
