Adds some additional eager cache invalidation to ensure we don't use stale nodes

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1301145 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-03-15 18:57:13 +00:00
parent d4cd7f9eed
commit eab8758529
1 changed files with 7 additions and 0 deletions

View File

@ -155,6 +155,7 @@ public class ListIndex<Key,Value> implements Index<Key,Value> {
oldValue = lastGetEntryCache.setValue(value); oldValue = lastGetEntryCache.setValue(value);
lastGetEntryCache.setValue(value); lastGetEntryCache.setValue(value);
lastGetNodeCache.storeUpdate(tx); lastGetNodeCache.storeUpdate(tx);
flushCache();
return oldValue; return oldValue;
} }
@ -166,6 +167,7 @@ public class ListIndex<Key,Value> implements Index<Key,Value> {
if (entry.getKey().equals(key)) { if (entry.getKey().equals(key)) {
oldValue = entry.setValue(value); oldValue = entry.setValue(value);
((ListIterator) iterator).getCurrent().storeUpdate(tx); ((ListIterator) iterator).getCurrent().storeUpdate(tx);
flushCache();
return oldValue; return oldValue;
} }
} }
@ -182,11 +184,14 @@ public class ListIndex<Key,Value> implements Index<Key,Value> {
if (entry.getKey().equals(key)) { if (entry.getKey().equals(key)) {
oldValue = entry.setValue(value); oldValue = entry.setValue(value);
((ListIterator) iterator).getCurrent().storeUpdate(tx); ((ListIterator) iterator).getCurrent().storeUpdate(tx);
flushCache();
return oldValue; return oldValue;
} }
} }
// Not found so add it last. // Not found so add it last.
flushCache();
return add(tx, key, value); return add(tx, key, value);
} }
@ -194,6 +199,7 @@ public class ListIndex<Key,Value> implements Index<Key,Value> {
assertLoaded(); assertLoaded();
getTail(tx).put(tx, key, value); getTail(tx).put(tx, key, value);
size.incrementAndGet(); size.incrementAndGet();
flushCache();
return null; return null;
} }
@ -201,6 +207,7 @@ public class ListIndex<Key,Value> implements Index<Key,Value> {
assertLoaded(); assertLoaded();
getHead(tx).addFirst(tx, key, value); getHead(tx).addFirst(tx, key, value);
size.incrementAndGet(); size.incrementAndGet();
flushCache();
return null; return null;
} }