title: How to clear cache object (memory) through Java
body: <p>Code snippet used to allocate cache memory:</p>
  
  <pre><code>private static Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
  
  public static HashMap&lt;String, XXX&gt; getxxCodes(int version) {
          HashMap&lt;String, XXX&gt; xxCodes = new HashMap&lt;String, XXX&gt;();
          try{
              Object[] cacheResult = cache.get(Constants.I_XX_CODES_FOR_XXX);
              if (Boolean.FALSE.equals(cacheResult[1])) {
          cache.put(Constants.I_XX_CODES_FOR_XXX, id.loadXXHashMap(version));
                  cacheResult = cache.get(Constants.I_XX_CODES_FOR_XXX);
              }
              if(cacheResult[0]!=null){
                  xxCodes = (HashMap&lt;String, XXX&gt;)cacheResult[0];
              }
          }catch(Exception e){
              logger.error("Exception occured while loading Data from I10_DRG_XX",e);
          }
          return xxCodes;
      }
  </code></pre>
  
  <p>Now at some point of time I need to load some other "version" into the cache memory. Here version can be 1, 2, 3 etc. So the cache first holds version 1 data (Hash map). Now when I am passing 2 which is unavailable in cache it needs to load specific data again into cache, but before that it is better to clear version 1 data. Do we have commands like flush to clear specific data?</p>
  
  <p>I hope I am clear with my question. Thanks for helping.</p>