mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged 1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4380 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4386 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4659 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
package org.alfresco.repo.cache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
@@ -226,6 +228,39 @@ public class TransactionalCache<K extends Serializable, V extends Serializable>
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The keys returned are a union of the set of keys in the current transaction and
|
||||
* those in the backing cache.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<K> getKeys()
|
||||
{
|
||||
Collection<K> keys = null;
|
||||
// in-txn layering
|
||||
if (AlfrescoTransactionSupport.getTransactionId() != null)
|
||||
{
|
||||
keys = new HashSet<K>(23);
|
||||
TransactionData txnData = getTransactionData();
|
||||
if (!txnData.isClearOn)
|
||||
{
|
||||
// the backing cache is not due for a clear
|
||||
Collection<K> backingKeys = (Collection<K>) sharedCache.getKeys();
|
||||
keys.addAll(backingKeys);
|
||||
}
|
||||
// add keys
|
||||
keys.addAll((Collection<K>) txnData.updatedItemsCache.getKeys());
|
||||
// remove keys
|
||||
keys.removeAll((Collection<K>) txnData.removedItemsCache.getKeys());
|
||||
}
|
||||
else
|
||||
{
|
||||
// no transaction, so just use the backing cache
|
||||
keys = (Collection<K>) sharedCache.getKeys();
|
||||
}
|
||||
// done
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the per-transaction caches for the object before going to the shared cache.
|
||||
|
Reference in New Issue
Block a user