public class ConcurrentCache<K,V> extends AbstractCache
Constructor and Description |
---|
ConcurrentCache(String name) |
ConcurrentCache(String name,
int numberOfSegments) |
Modifier and Type | Method and Description |
---|---|
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 zero.
|
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() |
List<V> |
values()
Returns all values in the cache.
|
dispose, getAccessCount, getCacheInfoAsString, getMaxMemorySize, getMemoryUsed, getMissCount, getTotalAccessCount, isTooBig, recordCacheAccess, recordCacheMiss, recordSizeChange, resetAccessCount, resetMissCount, setAccessListener
public ConcurrentCache(String name, int numberOfSegments)
public ConcurrentCache(String name)
public boolean containsKey(K key)
key
- entry keytrue
if the entry is cached,
false
otherwisepublic V get(K key)
key
- entry keynull
if not foundpublic List<V> values()
public V put(K key, V value, long size)
key
- entry keyvalue
- entry valuesize
- entry sizenull
public V remove(K key)
key
- entry keynull
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
Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.