Rails.cache.fetch not overwriting current value

If you notice a Rails cache call not overwriting the previously entered value, for instance:

Rails.cache.fetch("your_key") do 
  your_random_value
end

 
Try passing the force flag to fetch, like this:

Rails.cache.fetch("your_key", :force=>true) do 
  your_random_value
end

 
And it should work without a problem.

Leave a Reply

Your email address will not be published. Required fields are marked *