Please explain the behaviour of Rails's cache in this case <p>Imagine I have 5 tags: <code>tag1,tag2...tag5</code>. If I do the following:</p> <pre><code>Rails.cache.fetch("all.tags") { Tag.all } </code></pre> <p>and afterwards I write <code>Rails.cache.fetch("all.tags")</code>, I see the 5 tags. If I add another tag, and I try to fetch from the cache again, the new tag is also loaded. Why is that?</p> <p>EDIT: Here's my actual code:</p> <pre><code>Rails.cache.fetch("autocomplete.#{term}") { puts "Cache miss #{term}"; Tag.starting_with(term) } </code></pre> <p>Where <code>starting_with</code> is doing a where to find tags starting with certain letters. Here's the behaviour I get in the console:</p> <pre><code>1.9.3p125 :046 &gt; Rails.cache.read("autocomplete.ta") Tag Load (1.0ms) SELECT "tags".* FROM "tags" WHERE (name like 'ta%') =&gt; [#&lt;Tag id: 10, name: "tag1"&gt;, #&lt;Tag id: 11, name: "tag2"&gt;, #&lt;Tag id: 12, name: "tag3"&gt;, #&lt;Tag id: 13, name: "tag4"&gt;] 1.9.3p125 :048 &gt; Tag.create(name:"tag5") (0.2ms) begin transaction SQL (1.0ms) INSERT INTO "tags" ("name") VALUES (?) [["name", "tag5"]] (150.9ms) commit transaction =&gt; #&lt;Tag id: 14, name: "tag5"&gt; 1.9.3p125 :049 &gt; Rails.cache.read("autocomplete.ta") Tag Load (0.8ms) SELECT "tags".* FROM "tags" WHERE (name like 'ta%') =&gt; [#&lt;Tag id: 10, name: "tag1"&gt;, #&lt;Tag id: 11, name: "tag2"&gt;, #&lt;Tag id: 12, name: "tag3"&gt;, #&lt;Tag id: 13, name: "tag4"&gt;, #&lt;Tag id: 14, name: "tag5"&gt;] </code></pre>