title: How should I use @CachePut and @CacheEvict annotations with ehCache (ehCache 2.4.4, Spring 3.1.1)
body: <p>I tried some new Spring features and I found out that @CachePut and @CacheEvict annotations has no effect. May be I do something wrong. Could you help me?</p>
  
  <p>My applicationContext.xml.</p>
  
  <pre><code>&lt;cache:annotation-driven /&gt;
  
  &lt;!--also tried this--&gt;
  &lt;!--&lt;ehcache:annotation-driven /&gt;--&gt;
  
  &lt;bean id="cacheManager" 
          class="org.springframework.cache.ehcache.EhCacheCacheManager"
          p:cache-manager-ref="ehcache"/&gt;
  &lt;bean id="ehcache"
          class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
          p:config-location="classpath:ehcache.xml"/&gt;
  </code></pre>
  
  <p>This part works well.</p>
  
  <pre><code>@Cacheable(value = "finders")
  public Finder getFinder(String code)
  {
      return getFinderFromDB(code);
  }
  
  @CacheEvict(value = "finders", allEntries = true)
  public void clearCache()
  {
  }
  </code></pre>
  
  <p>But if I want remove single value from cache or override it I can't do that. What I tested:</p>
  
  <pre><code>@CacheEvict(value = "finders", key = "#finder.code")
  public boolean updateFinder(Finder finder, boolean nullValuesAllowed)
  {
      // ...
  }
  
  /////////////
  
  @CacheEvict(value = "finders")
  public void clearCache(String code)
  {
  }
  
  /////////////
  
  @CachePut(value = "finders", key = "#finder.code")
  public Finder updateFinder(Finder finder, boolean nullValuesAllowed)
  {
      // gets newFinder that is different
      return newFinder;
  }
  </code></pre>