Package org.apache.jackrabbit.core.state
Class MLRUItemStateCache
- java.lang.Object
-
- org.apache.jackrabbit.core.state.MLRUItemStateCache
-
- All Implemented Interfaces:
ItemStateCache
public class MLRUItemStateCache extends Object implements ItemStateCache
AnItemStateCacheimplementation that internally uses aConcurrentCacheto maintain a cache ofItemStateobjects. The cache uses a rough estimate of the memory consumption of the cached item states for calculating the maximum number of entries. The oldest entries are flushed once the cache size has exceeded a certain limit.TODO rename class to something more appropriate, e.g. FIFOItemSateCache since it doesn't use a LRU eviction policy anymore.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_MEMdefault maximum memory to use
-
Constructor Summary
Constructors Constructor Description MLRUItemStateCache(CacheManager cacheMgr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcache(ItemState state)Stores the specifiedItemStateobject in the map using itsItemIdas the key.voiddispose()Informs the cache that it is no longer in use.voidevict(ItemId id)Removes theItemStateobject with the specified id from this cache if it is present.voidevictAll()Clears all entries from this cache.booleanisCached(ItemId id)Returnstrueif this cache contains anItemStateobject with the specifiedid.booleanisEmpty()Returnstrueif this cache contains no entries.ItemStateretrieve(ItemId id)Returns theItemStateobject with the specifiedidif it is present ornullif no entry exists with thatid.ItemState[]retrieveAll()Returns all the cached item states.
-
-
-
Field Detail
-
DEFAULT_MAX_MEM
public static final int DEFAULT_MAX_MEM
default maximum memory to use- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MLRUItemStateCache
public MLRUItemStateCache(CacheManager cacheMgr)
-
-
Method Detail
-
isCached
public boolean isCached(ItemId id)
Returnstrueif this cache contains anItemStateobject with the specifiedid.- Specified by:
isCachedin interfaceItemStateCache- Parameters:
id- id ofItemStateobject whose presence should be tested.- Returns:
trueif there's a corresponding cache entry, otherwisefalse.
-
retrieve
public ItemState retrieve(ItemId id)
Returns theItemStateobject with the specifiedidif it is present ornullif no entry exists with thatid.- Specified by:
retrievein interfaceItemStateCache- Parameters:
id- the id of theItemStateobject to be returned.- Returns:
- the
ItemStateobject with the specifiedidor ornullif no entry exists with thatid
-
retrieveAll
public ItemState[] retrieveAll()
Returns all the cached item states.- Specified by:
retrieveAllin interfaceItemStateCache- Returns:
- newly allocated item state array
-
cache
public void cache(ItemState state)
Stores the specifiedItemStateobject in the map using itsItemIdas the key.- Specified by:
cachein interfaceItemStateCache- Parameters:
state- theItemStateobject to cache
-
evict
public void evict(ItemId id)
Removes theItemStateobject with the specified id from this cache if it is present.- Specified by:
evictin interfaceItemStateCache- Parameters:
id- the id of theItemStateobject which should be removed from this cache.
-
evictAll
public void evictAll()
Clears all entries from this cache.- Specified by:
evictAllin interfaceItemStateCache
-
isEmpty
public boolean isEmpty()
Returnstrueif this cache contains no entries.- Specified by:
isEmptyin interfaceItemStateCache- Returns:
trueif this cache contains no entries.
-
dispose
public void dispose()
Informs the cache that it is no longer in use.- Specified by:
disposein interfaceItemStateCache
-
-