title: Rails model caching
body: <p>I have two models, called <code>Division</code> and <code>Tier</code>, which are queried a lot, but inserts or updates are hardly ever done. The tables only have a handful or records in, so the whole tables can be stored in memory.</p>
  
  <pre><code>class Division
    # position: integer
    belongs_to :tier
  end
  
  class Tier
    # name: string
    has_many :tiers
  end
  </code></pre>
  
  <p>These tables are queried in almost every page, so it seems like a waste of database calls</p>
  
  <p>Model caching solutions like <a href="https://github.com/Shopify/identity_cache" rel="nofollow">identity cache</a>, which cache records in memcached, only allow you to retrieve records from the cache by id.</p>
  
  <p>A lot of queries are just selecting by id, but I also perform a lot of queries like</p>
  
  <pre><code>SELECT * FROM divisions WHERE divisions.position BETWEEN ? AND ?
  </code></pre>
  
  <p>I have a few questions</p>
  
  <ol>
  <li>Will the database cache these tables in memory by itself, making another caching solution unnecessary?</li>
  <li>If not, is there any way to cache these models in memory, and query against the cache using conditions other than just the id?</li>
  <li>Am I essentially asking for something with the speed of redis/memcached, but the features of a relational database, which isn't possible?</li>
  </ol>