mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Lookup caching is working. It's fairly heavy handed in its invalidation
strategy, but seems to give a 10-20% performance boost. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4426 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -51,6 +51,11 @@ public class LookupCache
|
||||
*/
|
||||
private AVMNodeDAO fAVMNodeDAO;
|
||||
|
||||
/**
|
||||
* Reference to the Store DAO.
|
||||
*/
|
||||
private AVMStoreDAO fAVMStoreDAO;
|
||||
|
||||
/**
|
||||
* Make one up.
|
||||
*/
|
||||
@@ -72,6 +77,15 @@ public class LookupCache
|
||||
fAVMNodeDAO = dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the store dao.
|
||||
* @param dao The dao to set.
|
||||
*/
|
||||
public void setAvmStoreDAO(AVMStoreDAO dao)
|
||||
{
|
||||
fAVMStoreDAO = dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum cache size.
|
||||
* @param maxSize
|
||||
@@ -165,6 +179,38 @@ public class LookupCache
|
||||
*/
|
||||
private synchronized Lookup findInCache(LookupKey key)
|
||||
{
|
||||
Lookup found = fCache.get(key);
|
||||
if (found != null)
|
||||
{
|
||||
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
|
||||
if (!result.isValid())
|
||||
{
|
||||
fgLogger.error("Invalid entry in cache: " + key);
|
||||
onRollback();
|
||||
return null;
|
||||
}
|
||||
updateCache(key, found);
|
||||
return result;
|
||||
}
|
||||
// Alternatively for a read lookup a write can match.
|
||||
if (!key.isWrite())
|
||||
{
|
||||
LookupKey newKey = new LookupKey(key);
|
||||
newKey.setWrite(true);
|
||||
found = fCache.get(newKey);
|
||||
if (found != null)
|
||||
{
|
||||
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
|
||||
if (!result.isValid())
|
||||
{
|
||||
fgLogger.error("Invalid entry in cache: " + newKey);
|
||||
onRollback();
|
||||
return null;
|
||||
}
|
||||
updateCache(newKey, found);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user