mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added cache clear method
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15778 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -621,6 +621,21 @@ public class EntityLookupCache<K extends Serializable, V extends Object, VK exte
|
|||||||
cache.remove(valueCacheKey);
|
cache.remove(valueCacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache-only operation: Remove all cache entries
|
||||||
|
* <p/>
|
||||||
|
* <b>NOTE:</b> This operation removes ALL entries for ALL cache regions.
|
||||||
|
*/
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
// Handle missing cache
|
||||||
|
if (cache == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key-wrapper used to separate cache regions, allowing a single cache to be used for different
|
* Key-wrapper used to separate cache regions, allowing a single cache to be used for different
|
||||||
* purposes.<b/>
|
* purposes.<b/>
|
||||||
|
@@ -213,6 +213,21 @@ public class EntityLookupCacheTest extends TestCase implements EntityLookupCallb
|
|||||||
assertNull(database.get(id));
|
assertNull(database.get(id));
|
||||||
assertEquals(0, cache.getKeys().size());
|
assertEquals(0, cache.getKeys().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testClear() throws Exception
|
||||||
|
{
|
||||||
|
TestValue valueOne = new TestValue(getName() + "-ONE");
|
||||||
|
Pair<Long, Object> entityPairOne = entityLookupCacheA.getOrCreateByValue(valueOne);
|
||||||
|
assertNotNull(entityPairOne);
|
||||||
|
Long id = entityPairOne.getFirst();
|
||||||
|
assertEquals(valueOne.val, database.get(id));
|
||||||
|
assertEquals(2, cache.getKeys().size());
|
||||||
|
|
||||||
|
// Clear it
|
||||||
|
entityLookupCacheA.clear();
|
||||||
|
assertEquals(valueOne.val, database.get(id)); // Must still be in database
|
||||||
|
assertEquals(0, cache.getKeys().size()); // ... but cache must be empty
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to represent business object
|
* Helper class to represent business object
|
||||||
|
Reference in New Issue
Block a user