|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.core.cache.AbstractCache
org.apache.jackrabbit.core.cache.ConcurrentCache<K,V>
public class ConcurrentCache<K,V>
Concurrent cache implementation that uses cache segments to minimize the chance of lock contention. The LRU algorithm is used to evict excess entries from each cache segment separately, which makes the combined eviction algorithm similar but not exactly the same as LRU. None of the methods of this class are synchronized, but they are all thread-safe.
Constructor Summary | |
---|---|
ConcurrentCache()
|
|
ConcurrentCache(int numberOfSegments)
|
Method Summary | |
---|---|
void |
clear()
Clears all segments of the cache. |
boolean |
containsKey(K key)
Checks if the identified entry is cached. |
V |
get(K key)
Returns the identified cache entry. |
boolean |
isEmpty()
Checks if the cache size is zore. |
V |
put(K key,
V value,
long size)
Adds the given entry to the cache. |
V |
remove(K key)
Removes the identified entry from the cache. |
void |
setMaxMemorySize(long size)
Sets the maximum size of the cache and evicts any excess items until the current size falls within the given limit. |
V[] |
values()
Returns all values in the cache. |
Methods inherited from class org.apache.jackrabbit.core.cache.AbstractCache |
---|
dispose, getAccessCount, getMaxMemorySize, getMemoryUsed, isTooBig, recordCacheAccess, recordSizeChange, resetAccessCount, setAccessListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConcurrentCache(int numberOfSegments)
public ConcurrentCache()
Method Detail |
---|
public boolean containsKey(K key)
key
- entry key
true
if the entry is cached,
false
otherwisepublic V get(K key)
key
- entry key
null
if not foundpublic V[] values()
public V put(K key, V value, long size)
key
- entry keyvalue
- entry valuesize
- entry size
null
public V remove(K key)
key
- entry key
null
if not foundpublic void clear()
public boolean isEmpty()
public void setMaxMemorySize(long size)
setMaxMemorySize
in interface Cache
setMaxMemorySize
in class AbstractCache
size
- the size in bytes
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |