title: Ehcache not removing an element from cache even after timeToLiveSeconds and/or timeToIdleSeconds
body: <p>Need a help here.
  I am working on a project where I have to delete elements(keys) when it is not used for a certain time. I tried with both timeToLiveSeconds and timeToIdleSeconds as 60 seconds. Also tried with only timeToLiveSeconds=60 and with only timeToIdleSeconds=60. But I still see that element in cache.</p>
  
  <p>fyi: I have some code to show all cached elements on the screen.</p>
  
  <p>Screenshot 0: Before calling REST service for my action. Expectation: the element Should NOT appear in the Cache Web page – Working as expected </p>
  
  <p>Screenshot 1: After calling REST service to execute my action. Expectation: See the element in the Cache list in the web page – Working as expected</p>
  
  <p>Now Idle for 60 seconds (do not call the REST service, means the element is not used for 60 seconds)</p>
  
  <p>Screenshot 2: Refresh the Cache Web page. Expectation: the element Should NOT appear in the Cache Web page – NOT working as expected</p>
  
  <ul>
  <li>element means AF2TDU2001</li>
  <li>We are using ehcache 2.5.2</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/TftVK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TftVK.png" alt="Screenshot 0"></a></p>
  
  <p><a href="https://i.stack.imgur.com/6QJd5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6QJd5.png" alt="Screenshot 1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/5LHrL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5LHrL.png" alt="Screenshot 2"></a></p>
  
  <p>Here is is my code:</p>
  
  <pre><code>/**
       * 
       * @param cacheName
       * @param diskPersistent
       */
      private static void addCache(String cacheName, boolean diskPersistent) {
          /*
              @param name - the name of the cache. Note that "default" is a reserved name for the defaultCache.
              @param maxElementsInMemory - the maximum number of elements in memory, before they are evicted (0 == no limit)
              @param memoryStoreEvictionPolicy - one of LRU, LFU and FIFO. Optionally null, in which case it will be set to LRU.
              @param overflowToDisk - whether to use the disk store
              @param diskStorePath - this parameter is ignored. CacheManager sets it using setter injection.
              @param eternal - whether the elements in the cache are eternal, i.e. never expire
              @param timeToLiveSeconds - the default amount of time to live for an element from its creation date
              @param timeToIdleSeconds - the default amount of time to live for an element from its last accessed or modified date
              @param diskPersistent - whether to persist the cache to disk between JVM restarts
              @param diskExpiryThreadIntervalSeconds - how often to run the disk store expiry thread. A large number of 120 seconds plus is @param recommended
              @param registeredEventListeners - a notification service. Optionally null, in which case a new one with no registered listeners will @param be created.
              @param bootstrapCacheLoader - the BootstrapCacheLoader to use to populate the cache when it is first initialised. Null if none is @param required.
              @param maxElementsOnDisk - the maximum number of Elements to allow on the disk. 0 means unlimited.
              @param diskSpoolBufferSizeMB - the amount of memory to allocate the write buffer for puts to the DiskStore.
           */
          Cache cache = new Cache(cacheName,
                  10000, // maxElementsInMemory
                  MemoryStoreEvictionPolicy.LRU,  // memoryStoreEvictionPolicy
                  false, // overflowToDisk
                  diskStorePath,
                  true,  // eternal
                  60,  // timeToLiveSeconds
                  60,  // timeToIdleSeconds
                  false, // diskPersistent
                  1,  // diskExpiryThreadIntervalSeconds
                  null,
                  null,
                  0,  // bootstrapCacheLoader
                  0,  // maxElementsOnDisk
                  false);
          cacheManager.addCache(cache);
      }
  </code></pre>