From 744c4cf3d5f98005ee533efd09005eb9c319cd8e Mon Sep 17 00:00:00 2001 From: zell Date: Thu, 17 Jul 2008 12:16:39 +0000 Subject: [PATCH] Always do a (potentially distributed) cache remove on invalidation, regardless of what's in the local cache. From Kyle Sampson. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2335 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../jdbc/depot/PersistenceContext.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java index d4b266c5..518ccfd0 100644 --- a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java +++ b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java @@ -371,28 +371,25 @@ public class PersistenceContext CacheAdapter.CacheBin bin = _cache.getCache(cacheId); CacheAdapter.CachedValue element = bin.lookup(cacheKey); - if (element == null) { - return; - } - - // find the old entry, if any - T oldEntry = element.getValue(); - if (oldEntry != null) { - // if there was one, do (possibly cascading) cache invalidations - Set> listeners = _listenerSets.get(cacheId); - if (listeners != null && listeners.size() > 0) { - CacheKey key = new SimpleCacheKey(cacheId, cacheKey); - for (CacheListener listener : listeners) { - log.debug("cascading [listener=" + listener + "]"); - @SuppressWarnings("unchecked") CacheListener casted = - (CacheListener)listener; - casted.entryInvalidated(key, oldEntry); + if (element != null) { + // find the old entry, if any + T oldEntry = element.getValue(); + if (oldEntry != null) { + // if there was one, do (possibly cascading) cache invalidations + Set> listeners = _listenerSets.get(cacheId); + if (listeners != null && listeners.size() > 0) { + CacheKey key = new SimpleCacheKey(cacheId, cacheKey); + for (CacheListener listener : listeners) { + log.debug("cascading [listener=" + listener + "]"); + @SuppressWarnings("unchecked") CacheListener casted = + (CacheListener)listener; + casted.entryInvalidated(key, oldEntry); + } } } } - // then evict the keyed entry, if needed - log.debug("evicting [cacheKey=" + cacheKey + "]"); + // then remove the keyed entry from the cache system bin.remove(cacheKey); }