org.apache.jackrabbit.core.state
Class LRUItemStateCache

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.LRUItemStateCache
All Implemented Interfaces:
ItemStateCache

public class LRUItemStateCache
extends Object
implements ItemStateCache

An ItemStateCache implementation that internally uses a LRUMap to maintain a cache of ItemState objects.


Field Summary
static int DEFAULT_MAX_SIZE
          default maximum size of this cache
 
Constructor Summary
LRUItemStateCache()
          Constructs a new, empty ItemStateCache with a maximum size of 1000.
LRUItemStateCache(int maxSize)
          Constructs a new, empty ItemStateCache with the specified maximum size.
 
Method Summary
 void cache(ItemState state)
          Stores the specified ItemState object in the map using its ItemId as the key.
 void evict(ItemId id)
          Removes the ItemState object with the specified id from this cache if it is present.
 void evictAll()
          Clears all entries from this cache.
 boolean isCached(ItemId id)
          Returns true if this cache contains an ItemState object with the specified id.
 boolean isEmpty()
          Returns true if this cache contains no entries.
 Set keySet()
          Returns an unmodifiable set view of the keys (i.e. ItemId objects) of the cached entries.
 ItemState retrieve(ItemId id)
          Returns the ItemState object with the specified id if it is present or null if no entry exists with that id.
 int size()
          Returns the number of entries in this cache.
 Collection values()
          Returns an unmodifiable collection view of the values (i.e. ItemState objects) contained in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_SIZE

public static final int DEFAULT_MAX_SIZE
default maximum size of this cache

See Also:
Constant Field Values
Constructor Detail

LRUItemStateCache

public LRUItemStateCache()
Constructs a new, empty ItemStateCache with a maximum size of 1000.


LRUItemStateCache

public LRUItemStateCache(int maxSize)
Constructs a new, empty ItemStateCache with the specified maximum size.

Parameters:
maxSize - the maximum size of the cache, -1 for no limit,
Method Detail

isCached

public boolean isCached(ItemId id)
Returns true if this cache contains an ItemState object with the specified id.

Specified by:
isCached in interface ItemStateCache
Parameters:
id - id of ItemState object whose presence should be tested.
Returns:
true if there's a corresponding cache entry, otherwise false.

retrieve

public ItemState retrieve(ItemId id)
Returns the ItemState object with the specified id if it is present or null if no entry exists with that id.

Specified by:
retrieve in interface ItemStateCache
Parameters:
id - the id of the ItemState object to be returned.
Returns:
the ItemState object with the specified id or or null if no entry exists with that id

cache

public void cache(ItemState state)
Stores the specified ItemState object in the map using its ItemId as the key.

Specified by:
cache in interface ItemStateCache
Parameters:
state - the ItemState object to cache

evict

public void evict(ItemId id)
Removes the ItemState object with the specified id from this cache if it is present.

Specified by:
evict in interface ItemStateCache
Parameters:
id - the id of the ItemState object which should be removed from this cache.

evictAll

public void evictAll()
Clears all entries from this cache.

Specified by:
evictAll in interface ItemStateCache

isEmpty

public boolean isEmpty()
Returns true if this cache contains no entries.

Specified by:
isEmpty in interface ItemStateCache
Returns:
true if this cache contains no entries.

size

public int size()
Returns the number of entries in this cache.

Specified by:
size in interface ItemStateCache
Returns:
number of entries in this cache.

keySet

public Set keySet()
Returns an unmodifiable set view of the keys (i.e. ItemId objects) of the cached entries.

Specified by:
keySet in interface ItemStateCache
Returns:
a set view of the keys of the cached entries.

values

public Collection values()
Returns an unmodifiable collection view of the values (i.e. ItemState objects) contained in this cache.

Specified by:
values in interface ItemStateCache
Returns:
a collection view of the values contained in this cache.


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.