title: How can I remove a particular key from Cache using Java Spring
body: <p>I want to remove particular cache keys. I am using java spring.
  I have different keys under same cache name. I have to remove some particular keys, not the whole cache.<br>
  The cache code is as below,</p>
  
  <pre><code>@CacheEvict(value="MyCache", key="CACHE_LIST_COLUMNS + #accountId + '_' + #formType")
  public void addListColumn(){.. my code..}
  
  @CacheEvict(value="MyCache", key="CACHE_SUMMARY_FIELDS + #accountId + '_' + #formType")
  public void addSummaryColumn(){.. my code..}
  </code></pre>
  
  <p>Now as you can see under name 'MyCache' I have to different caches with different keys. Can someone guide me how we can get the particular key from a particular cache and remove that cache. </p>
  
  <p>I want to remove this cache list:</p>
  
  <pre><code>value="MyCache", key="CACHE_SUMMARY_FIELDS + #accountId + '_' + #formType"
  </code></pre>
  
  <p>This is what I am trying</p>
  
  <pre><code> StringBuffer cacheNames = new StringBuffer();
  
   for (String cacheName : getCacheManager().getCacheNames()) {   
      Cache cache = getCacheManager().getCache(cacheName);
    cache.clear();
   }
  </code></pre>
  
  <p>What this code does is gets cache of name 'MyCache' and clears this whole MyCache. But I don't want to clear all the cache entries. 
  For example the keys are,</p>
  
  <pre><code>CacheEvict(value="MyCache", key="CACHE_LIST_COLUMNS + 10000 + '_' + 3")
  CacheEvict(value="MyCache", key="CACHE_SUMMARY_FIELDS + 10000 + '_' + 4")
  </code></pre>
  
  <p>So the keys are Key1 = CACHE_LIST_COLUMNS10000_3</p>
  
  <pre><code>            Key2 = CACHE_SUMMARY_FIELDS10000_4
  </code></pre>
  
  <p>Now I want to remove only key CACHE_LIST_COLUMNS10000_3.
  Hence how can I get the cache 'MyCache' and Key CACHE_LIST_COLUMNS10000_3,
  and remove only data related to this key(CACHE_LIST_COLUMNS10000_3).</p>
  
  <p>I have to explicitly remove cache through java code. Not through annotations.
  What my function will be is get cache keys as input and delete only those particular keys.</p>
  
  <p>If still you don't understand my question please let me know.</p>