title: What strategies exist for using Spring Cache on methods that take an array or collection parameter?
body: <p>I want to use Spring's Cache abstraction to annotate methods as @Cacheable. However, some methods are designed to take an array or collection of parameters and return a collection. For example, consider this method to find entites:</p>
  
  <pre><code>public Collection&lt;Entity&gt; getEntities(Collection&lt;Long&gt; ids)
  </code></pre>
  
  <p>Semantically, I need to cache <code>Entity</code> objects individually (keyed by id), not based on the collection of IDs as a whole. Similar to what <a href="https://stackoverflow.com/questions/13178723/spring-cache-abstraction-with-multi-value-queries">this question</a> is asking about.</p>
  
  <p><a href="https://stackoverflow.com/questions/13178723/spring-cache-abstraction-with-multi-value-queries">Simple Spring Memcached</a> supports what I want, via its <a href="https://stackoverflow.com/questions/13178723/spring-cache-abstraction-with-multi-value-queries"><code>ReadThroughMultiCache</code></a>, but I want to use Spring's abstraction in order to support easy changing of the cache store implementation (Guava, Coherence, Hazelcast, etc), not just memcached.</p>
  
  <p>What strategies exist for caching this kind of method using Spring Cache?</p>