title: spring cache expire using bean property
body: <p>Is there a way of indicating to expire/evict the cache object based on a property of the POJO cached.</p>
  
  <p>In below code, it caches <code>Foo</code> instance. Foo class has a <code>expiresIn</code> property
  class Foo {
      Date expiresIn;
  }</p>
  
  <p>I want to hint to spring to expire the cache based on the value of <code>expiresIn</code> property of cached element. Is this feasible?</p>
  
  <pre class="lang-java prettyprint-override"><code>@Cacheable("my-cache-key")
      Foo getCachedToken(String userName, String password) throws AuthException
  </code></pre>
  
  <p>My Cache.xml is below:
  </p>
  
  <pre><code>&lt;cache:annotation-driven/&gt;
  
  &lt;bean id="cacheManager" class="org.springframework.cache.support.CompositeCacheManager"&gt;
      &lt;property name="cacheManagers"&gt;
          &lt;list&gt;
              &lt;ref bean="mapCacheManager"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="mapCacheManager" class="org.springframework.cache.concurrent.ConcurrentMapCacheManager"&gt;
      &lt;property name="cacheNames"&gt;
          &lt;list&gt;
              &lt;value&gt;my-cache-key&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>