Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 1060:cc4ec127d666
Remove the elements of an outdated state from cache if its endOfLife method is called.
gnv-artifacts/trunk@1143 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 01 Jun 2010 16:54:21 +0000 |
parents | 9981452c7e75 |
children | f953c9a559d8 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon May 31 08:20:17 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Tue Jun 01 16:54:21 2010 +0000 @@ -959,7 +959,7 @@ } - protected String getHash(String uuid) { + protected String getHash() { return this.hash; } @@ -969,7 +969,7 @@ if (factory.isInitialized()) { // we use a cache Cache cache = factory.getCache(); - String key = getHash(uuid); + String key = getHash(); log.debug("Using cache - key: " + key); @@ -1059,6 +1059,17 @@ public void endOfLife(Object globalContext) { + log.debug("end of life of the current state."); + + CacheFactory factory = CacheFactory.getInstance(); + if (factory.isInitialized()) { + Cache cache = factory.getCache(); + String key = getHash(); + + if (key != null && cache.remove(key)) { + log.info("Removed element from cache - key: " + key); + } + } }