title: Maintaining multiple indexes with guava cache (in-memory table)
body: <p>I'm trying to implement a simplified in-memory cached "table" where there are 2 types of indexes: primary and secondary.</p>
  
  <ul>
  <li><p><strong>Primary index</strong> maps a single key (primary key) to a unique value (Map interface)</p></li>
  <li><p><strong>Secondary index</strong> maps a single key to a Collection of values (Multimap fits the bill) </p></li>
  </ul>
  
  <p>Very similar to a table in RDBMS world where one has several lookup columns. Sometimes you want to search by PK, sometimes return a list of rows based on a common property. Right now, there is no need in other operations than equals (=) (ie no range queries, or pattern matching).</p>
  
  <p>Add cache semantics to the above data structure (eviction, data population/cache loader, refresh etc.) and that's pretty much what is needed.</p>
  
  <p>I would like to ask your advice on how to best approach given problem. Should it be Cache per index or Cache (for PK) + (synchronized) Multimap for secondary indexes ?</p>
  
  <p>Any help is much appreciated.</p>
  
  <p>Regards.</p>