|
||||||||||
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(String name)
|
|
ConcurrentCache(String name,
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. |
long |
getElementCount()
Get the number of elements/objects in the cache. |
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. |
String |
toString()
|
V[] |
values()
Returns all values in the cache. |
Methods inherited from class org.apache.jackrabbit.core.cache.AbstractCache |
---|
dispose, getAccessCount, getCacheInfoAsString, getMaxMemorySize, getMemoryUsed, getMissCount, getTotalAccessCount, isTooBig, recordCacheAccess, recordCacheMiss, recordSizeChange, resetAccessCount, resetMissCount, setAccessListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConcurrentCache(String name, int numberOfSegments)
public ConcurrentCache(String name)
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 bytespublic long getElementCount()
Cache
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |