|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.openjpa.util.CacheMap
public class CacheMap
Fixed-size map that has ability to pin/unpin entries and move overflow to a backing soft map.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Field Summary | |
---|---|
protected SizedMap |
cacheMap
The map for non-expired and non-pinned references. |
protected Map |
pinnedMap
The set of objects pinned into the cache. |
protected SizedMap |
softMap
The map for expired references. |
Constructor Summary | |
---|---|
CacheMap()
Create a non-LRU (and therefore highly concurrent) cache map with a size of 1000. |
|
CacheMap(boolean lru,
int max)
Create a cache map with the given properties. |
|
CacheMap(boolean lru,
int max,
int size,
float load)
Deprecated. use CacheMap(boolean, int, int, float, int)
instead. |
|
CacheMap(boolean lru,
int max,
int size,
float load,
int concurrencyLevel)
Create a cache map with the given properties. |
Method Summary | |
---|---|
protected void |
cacheMapOverflowRemoved(Object key,
Object value)
Called from SizedMap.overflowRemoved(java.lang.Object, java.lang.Object) in the cache map. |
void |
clear()
Removes pinned objects as well as unpinned ones. |
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object val)
|
protected void |
entryAdded(Object key,
Object value)
Invoked when an entry is added to the cache. |
protected void |
entryRemoved(Object key,
Object value,
boolean expired)
Invoked when a key-value pair is evicted from this data structure. |
Set |
entrySet()
|
Object |
get(Object key)
|
int |
getCacheSize()
The maximum number of hard references to maintain, or -1 for no limit. |
Set |
getPinnedKeys()
The keys pinned into the map. |
int |
getSoftReferenceSize()
The maximum number of soft references to maintain, or -1 for no limit. |
boolean |
isEmpty()
|
boolean |
isLRU()
Whether this cache map uses LRU eviction. |
Set |
keySet()
|
boolean |
pin(Object key)
Locks the given key and its value into the map. |
protected Object |
put(Map map,
Object key,
Object value)
Put the given entry into the given map. |
Object |
put(Object key,
Object value)
|
void |
putAll(Map map)
|
void |
putAll(Map map,
boolean replaceExisting)
|
void |
readLock()
Acquire read lock. |
void |
readUnlock()
Release read lock. |
protected Object |
remove(Map map,
Object key)
Remove the given key from the given map. |
Object |
remove(Object key)
If key is pinned into the cache, the pin is
cleared and the object is removed. |
void |
setCacheSize(int size)
The maximum number of hard references to maintain, or -1 for no limit. |
void |
setSoftReferenceSize(int size)
The maximum number of soft references to maintain, or -1 for no limit. |
int |
size()
|
protected void |
softMapOverflowRemoved(Object key,
Object value)
Called from SizedMap.overflowRemoved(java.lang.Object, java.lang.Object) in the soft map. |
protected void |
softMapValueExpired(Object key)
Called when a value expires from the soft map. |
String |
toString()
|
boolean |
unpin(Object key)
Undo a pinning. |
Collection |
values()
|
void |
writeLock()
Acquire write lock. |
void |
writeUnlock()
Release write lock. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Field Detail |
---|
protected final SizedMap cacheMap
protected final SizedMap softMap
protected final Map pinnedMap
Constructor Detail |
---|
public CacheMap()
public CacheMap(boolean lru, int max)
public CacheMap(boolean lru, int max, int size, float load)
CacheMap(boolean, int, int, float, int)
instead.
public CacheMap(boolean lru, int max, int size, float load, int concurrencyLevel)
Method Detail |
---|
protected void cacheMapOverflowRemoved(Object key, Object value)
SizedMap.overflowRemoved(java.lang.Object, java.lang.Object)
in the cache map.
protected void softMapOverflowRemoved(Object key, Object value)
SizedMap.overflowRemoved(java.lang.Object, java.lang.Object)
in the soft map.
protected void softMapValueExpired(Object key)
protected Object put(Map map, Object key, Object value)
protected Object remove(Map map, Object key)
public void readLock()
public void readUnlock()
public void writeLock()
public void writeUnlock()
public boolean isLRU()
public void setCacheSize(int size)
public int getCacheSize()
public void setSoftReferenceSize(int size)
public int getSoftReferenceSize()
public Set getPinnedKeys()
public boolean pin(Object key)
public boolean unpin(Object key)
protected void entryRemoved(Object key, Object value, boolean expired)
expired
set to
true
when an object is dropped because of space
requirements or through garbage collection of soft references.
It is invoked with expired
set to false
when an object is explicitly removed via the remove(java.util.Map, java.lang.Object)
or
clear()
methods. This may be invoked more than once for a
given entry.
value
- may be null if the value was a soft reference that has
been GCdprotected void entryAdded(Object key, Object value)
public Object get(Object key)
get
in interface Map
public Object put(Object key, Object value)
put
in interface Map
public void putAll(Map map)
putAll
in interface Map
public void putAll(Map map, boolean replaceExisting)
public Object remove(Object key)
key
is pinned into the cache, the pin is
cleared and the object is removed.
remove
in interface Map
public void clear()
clear
in interface Map
public int size()
size
in interface Map
public boolean isEmpty()
isEmpty
in interface Map
public boolean containsKey(Object key)
containsKey
in interface Map
public boolean containsValue(Object val)
containsValue
in interface Map
public Set keySet()
keySet
in interface Map
public Collection values()
values
in interface Map
public Set entrySet()
entrySet
in interface Map
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |