Author: bpapez
Date: Tue Nov 13 11:51:47 2007
New Revision: 19129
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19129&repname=
=3Djahia
Log:
SNCF-31: Add functionality to allow expiring cache entries via setting the =
expiry date via the ProcessingContext
Modified:
trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.ja=
va
Modified: trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheI=
mpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/cache/treecache/TreeCacheImpl.java&rev=3D19129&repname=3D=
jahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.ja=
va (original)
+++ trunk/core/src/java/org/jahia/services/cache/treecache/TreeCacheImpl.ja=
va Tue Nov 13 11:51:47 2007
@@ -240,18 +240,10 @@
=
public void remove(Object entryKey) {
try {
- Fqn localFqn =3D null;
- if (entryKey instanceof List) {
- List entryList =3D (List) entryKey;
- localFqn =3D new Fqn(getFqn(), entryList);
- } else {
- localFqn =3D new Fqn(getFqn(), entryKey);
- }
+ Fqn localFqn =3D new Fqn(getFqn(),
+ entryKey instanceof List ? (List) entryKey : entryKey)=
; =
=
- TreeCache localTreeCache =3D getTreeCache();
- // if (localTreeCache.exists(localFqn)) {
- localTreeCache.remove(localFqn);
- // }
+ getTreeCache().remove(localFqn);
} catch (CacheException e) {
logger.warn(getName() + entryKey, e);
}
@@ -271,13 +263,20 @@
public CacheEntry getCacheEntry(Object entryKey) {
CacheEntry entry =3D null;
try {
- if (entryKey instanceof List) {
- List entryList =3D (List) entryKey;
- entry =3D (CacheEntry) getTreeCache().get(
- new Fqn(getFqn(), entryList), "entry");
- } else {
- entry =3D (CacheEntry) getTreeCache().get(
- new Fqn(getFqn(), entryKey), "entry");
+ Fqn entryFqnKey =3D new Fqn(getFqn(),
+ entryKey instanceof List ? (List) entryKey : entryKey);
+
+ entry =3D (CacheEntry) getTreeCache().get(
+ entryFqnKey, "entry");
+ // check if the entry is expired =
+ if (entry !=3D null
+ && entry.getExpirationDate() !=3D null
+ && entry.getExpirationDate().getTime() <=3D System
+ .currentTimeMillis()) {
+ // entry has expired, we must remove it and then exit.
+ logger.debug("Cache entry has expired, ignoring entry and =
removing...");
+ getTreeCache().remove(entryFqnKey);
+ entry =3D null;
}
} catch (CacheException e) {
logger.warn(getName() + entryKey, e);
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list