commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1593184 - /commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
Date Thu, 08 May 2014 05:49:10 GMT
Author: rmannibucau
Date: Thu May  8 05:49:09 2014
New Revision: 1593184

URL: http://svn.apache.org/r1593184
Log:
expiry event

Modified:
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java?rev=1593184&r1=1593183&r2=1593184&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
Thu May  8 05:49:09 2014
@@ -257,7 +257,7 @@ public class JCSCache<K extends Serializ
                 elt.update(expiryPolicy.getExpiryForAccess());
                 if (elt.isExpired())
                 {
-                    delegate.remove(cacheKey);
+                    expires(cacheKey);
                 }
                 else
                 {
@@ -301,7 +301,7 @@ public class JCSCache<K extends Serializ
         {
             if (!created)
             {
-                delegate.remove(cacheKey);
+                expires(cacheKey);
             }
         }
         else
@@ -334,6 +334,16 @@ public class JCSCache<K extends Serializ
         }
     }
 
+    private void expires(final JCSKey<K> cacheKey)
+    {
+        final JCSElement<V> elt = delegate.remove(cacheKey);
+        for (final JCSListener<K, V> listener : listeners.values())
+        {
+            listener.onExpired(Arrays.<CacheEntryEvent<? extends K, ? extends V>>
asList(new JCSCacheEntryEvent<K, V>(this,
+                    EventType.REMOVED, null, cacheKey.getKey(), elt.getElement())));
+        }
+    }
+
     @Override
     public V getAndPut(final K key, final V value)
     {
@@ -459,7 +469,7 @@ public class JCSCache<K extends Serializ
             elt.update(expiryPolicy.getExpiryForAccess());
             if (elt.isExpired())
             {
-                delegate.remove(key);
+                expires(key);
             }
             else
             {



Mime
View raw message