ALF-19779: Stack specific: Caches are no synchronized between the nodes

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54391 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2013-08-22 09:21:17 +00:00
parent eab5cddc79
commit 6ee97b2625
2 changed files with 52 additions and 2 deletions

View File

@@ -96,10 +96,21 @@ public final class DefaultSimpleCache<K extends Serializable, V extends Object>
@Override
public void put(K key, V value)
{
AbstractMap.SimpleImmutableEntry<K, V> kvp = new AbstractMap.SimpleImmutableEntry<K, V>(key, value);
map.put(key, kvp);
putAndCheckUpdate(key, value);
}
/**
* <code>put</code> method that may be used to check for updates in a thread-safe manner.
*
* @return <code>true</code> if the put resulted in a change in value, <code>false</code> otherwise.
*/
public boolean putAndCheckUpdate(K key, V value)
{
AbstractMap.SimpleImmutableEntry<K, V> kvp = new AbstractMap.SimpleImmutableEntry<K, V>(key, value);
AbstractMap.SimpleImmutableEntry<K, V> priorKVP = map.put(key, kvp);
return priorKVP != null && (! priorKVP.equals(kvp));
}
@Override
public void remove(K key)
{