|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
com.tangosol.util.AbstractKeySetBasedMap
com.tangosol.net.cache.SerializationMap
com.tangosol.net.cache.AbstractSerializationCache
com.tangosol.net.cache.SerializationCache
public class SerializationCache
A version of SerializationMap that implements an LRU policy.
This implementation is partially thread safe. It assumes that multiple threads will not be accessing the same keys at the same time, nor would any other thread be accessing this cache while a clear() operation were going on, for example. In other words, this implementation assumes that access to this cache is either single-threaded or gated through an object like WrapperConcurrentMap.
The primary reason why SerializationCache is a sub-class of SerializationMap instead of combining their functionality is that SerializationMap represents a passive store, and thus does not implement the ObservableMap interface, while SerializationCache represents an active store, and thus clients of it would have to always handle potential events, even if it were not size-limited.
Nested Class Summary | |
---|---|
protected class |
SerializationCache.EntryAttributes A class that holds on to the expiry time and touch order for an entry. |
class |
SerializationCache.EntrySet A set of entries backed by this map. |
static class |
SerializationCache.InternalEvictionPolicy The InternalEvictionPolicy represents a pluggable eviction policy for the non-pluggable built-in (internal) eviction policies supported by this cache implementation. |
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection |
Nested classes/interfaces inherited from interface com.tangosol.net.cache.ConfigurableCacheMap |
---|
ConfigurableCacheMap.Entry, ConfigurableCacheMap.EvictionPolicy, ConfigurableCacheMap.UnitCalculator |
Field Summary | |
---|---|
protected ConfigurableCacheMap.UnitCalculator |
m_calculator The unit calculator to use to limit size of the cache. |
protected long |
m_cCurUnits Current number of units to in the cache. |
protected long |
m_cMaxUnits Maximum number of units to manage in the cache. |
protected int |
m_nUnitFactor The unit factor. |
Fields inherited from interface com.tangosol.net.cache.CacheMap |
---|
EXPIRY_DEFAULT, EXPIRY_NEVER |
Constructor Summary | |
---|---|
SerializationCache(BinaryStore store, int cMax) Construct a SerializationCache on top of a BinaryStore. |
|
SerializationCache(BinaryStore store, int cMax, boolean fBinaryMap) Construct a SerializationCache on top of a BinaryStore. |
|
SerializationCache(BinaryStore store, int cMax, java.lang.ClassLoader loader) Construct a SerializationCache on top of a BinaryStore. |
Method Summary | |
---|---|
protected void |
checkExpiry() Make sure that the cache does not contain expired items. |
protected void |
checkSize() Make sure the size of the cache isn't too big. |
void |
clear() Clear all key/value mappings. |
boolean |
containsKey(java.lang.Object oKey) Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(java.lang.Object oValue) Returns true if this Map maps one or more keys to the specified value. |
void |
evict() Flush items that have expired. |
void |
evict(java.lang.Object oKey) Evict a specified key from the cache, as if it had expired from the cache. |
void |
evictAll(java.util.Collection colKeys) Evict the specified keys from the cache, as if they had each expired from the cache. |
void |
flush() Deprecated. use evict() |
java.lang.Object |
get(java.lang.Object oKey) Returns the value to which this map maps the specified key. |
ConfigurableCacheMap.Entry |
getCacheEntry(java.lang.Object oKey) Locate a cache Entry in the cache based on its key. |
protected java.lang.String |
getDescription() Assemble a human-readable description. |
ConfigurableCacheMap.EvictionPolicy |
getEvictionPolicy() Obtain the current EvictionPolicy used by the cache. |
protected LongArray |
getExpiryArray() Get the Expiry data structure. |
int |
getExpiryDelay() Determine the default "time to live" for each individual cache entry. |
int |
getFlushDelay() Determine the delay between cache flushes. |
int |
getHighUnits() Determine the limit of the cache size in units. |
int |
getLowUnits() Determine the point to which the cache will shrink when it prunes. |
protected LongArray |
getLruArray() Get the LRU data structure. |
int |
getMaximumSize() Deprecated. as of Coherence 3.5, use getHighUnits() |
protected long |
getTouchCounter() Determine the next value from the touch counter. |
ConfigurableCacheMap.UnitCalculator |
getUnitCalculator() Obtain the current UnitCalculator used by the cache. |
int |
getUnitFactor() Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted. |
int |
getUnits() Determine the number of units that the cache currently stores. |
SerializationCache.EntryAttributes |
instantiateEntryAttributes(SerializationCache.EntryAttributes attrOrig, long ldtExpires, long nTouch, int cUnits) Factory pattern: Construct an attribute holder for an entry. |
protected java.util.Set |
instantiateEntrySet() Factory pattern: Create a Set that represents the entries in the Map. |
boolean |
isEmpty() Returns true if this map contains no key-value mappings. |
java.lang.Object |
put(java.lang.Object oKey, java.lang.Object oValue) Associates the specified value with the specified key in this map. |
java.lang.Object |
put(java.lang.Object oKey, java.lang.Object oValue, long cMillis) Associates the specified value with the specified key in this cache. |
void |
putAll(java.util.Map map) Copies all of the mappings from the specified map to this map. |
protected void |
registerKey(java.lang.Object oKey, Binary binKey, Binary binValue) Register a new key for the SerializationMap. |
protected void |
registerKey(java.lang.Object oKey, Binary binKey, Binary binValue, int cMillis) Register a new key for the SerializationMap. |
java.lang.Object |
remove(java.lang.Object oKey) Removes the mapping for this key from this map if present. |
protected boolean |
removeBlind(java.lang.Object oKey) Removes the mapping for this key from this map if present. |
protected void |
setBinaryStore(BinaryStore store) Configures the BinaryStore that this map will use for its storage. |
void |
setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy) Set the EvictionPolicy for the cache to use. |
void |
setExpiryDelay(int cMillis) Specify the default "time to live" for cache entries. |
void |
setFlushDelay(int cMillis) Specify the delay between cache flushes. |
void |
setHighUnits(int cMax) Update the maximum size of the cache in units. |
void |
setLowUnits(int cUnits) Specify the point to which the cache will shrink when it prunes. |
void |
setMaximumSize(int cMax) Deprecated. as of Coherence 3.5, use setHighUnits(int) |
void |
setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator) Set the UnitCalculator for the cache to use. |
void |
setUnitFactor(int nFactor) Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted. |
int |
size() Returns the number of key-value mappings in this map. |
java.lang.String |
toString() Returns a string representation of this Map. |
protected void |
touch(java.lang.Object oKey) Touch an object to pop it to the top of the LRU |
protected void |
unregisterKey(java.lang.Object oKey) Unregister a key from the SerializationMap. |
Methods inherited from class com.tangosol.net.cache.AbstractSerializationCache |
---|
addMapListener, addMapListener, addMapListener, dispatchEvent, dispatchPendingEvent, getMapListenerSupport, hasListeners, removeMapListener, removeMapListener, removeMapListener |
Methods inherited from class com.tangosol.net.cache.SerializationMap |
---|
eraseStore, fromBinary, getBinaryStore, getCacheStatistics, getClassLoader, getInternalKeySet, getKeyMap, instantiateKeyMap, isBinaryMap, setBinaryMap, setClassLoader, toBinary |
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
instantiateKeyIterator, instantiateKeySet, instantiateValues, isInternalKeySetIteratorMutable, iterateKeys |
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap |
---|
clone, entrySet, equals, getAll, hashCode, keySet, values |
Methods inherited from interface com.tangosol.net.cache.CacheMap |
---|
getAll |
Methods inherited from interface com.tangosol.util.ObservableMap |
---|
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener |
Methods inherited from interface java.util.Map |
---|
entrySet, equals, hashCode, keySet, values |
Field Detail |
---|
protected long m_cMaxUnits
protected long m_cCurUnits
protected ConfigurableCacheMap.UnitCalculator m_calculator
protected int m_nUnitFactor
Constructor Detail |
---|
public SerializationCache(BinaryStore store, int cMax)
store
- the BinaryStore to use to write the serialized objects tocMax
- the maximum number of items to store in the binary storepublic SerializationCache(BinaryStore store, int cMax, java.lang.ClassLoader loader)
store
- the BinaryStore to use to write the serialized objects tocMax
- the maximum number of items to store in the binary storeloader
- the ClassLoader to use for deserializationpublic SerializationCache(BinaryStore store, int cMax, boolean fBinaryMap)
store
- the BinaryStore to use to write the serialized objects tocMax
- the maximum number of items to store in the binary storefBinaryMap
- true indicates that this map will only manage binary keys and valuesMethod Detail |
---|
public void clear()
clear
in interface java.util.Map
clear
in class AbstractSerializationCache
public boolean containsKey(java.lang.Object oKey)
containsKey
in interface java.util.Map
containsKey
in class AbstractKeySetBasedMap
oKey
- key whose presence in this map is to be tested.public boolean containsValue(java.lang.Object oValue)
containsValue
in interface java.util.Map
containsValue
in class SerializationMap
oValue
- value whose presence in this map is to be tested.public java.lang.Object get(java.lang.Object oKey)
get
in interface java.util.Map
get
in class SerializationMap
oKey
- the key objectMap.containsKey(Object)
public boolean isEmpty()
isEmpty
in interface java.util.Map
isEmpty
in class AbstractKeySetBasedMap
public java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue)
put
in interface CacheMap
put
in interface java.util.Map
put
in class AbstractSerializationCache
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keypublic void putAll(java.util.Map map)
AbstractKeyBasedMap.put(java.lang.Object, java.lang.Object)
on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.putAll
in interface java.util.Map
putAll
in class AbstractSerializationCache
map
- the Map containing the key/value pairings to put into this Mappublic java.lang.Object remove(java.lang.Object oKey)
remove
in interface java.util.Map
remove
in class AbstractSerializationCache
oKey
- key whose mapping is to be removed from the mappublic int size()
size
in interface java.util.Map
size
in class AbstractKeySetBasedMap
protected boolean removeBlind(java.lang.Object oKey)
removeBlind
in class AbstractSerializationCache
oKey
- key whose mapping is to be removed from the mappublic java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue, long cMillis)
CacheMap.put(Object oKey, Object oValue)
method allows the caller to specify an expiry (or "time to live") for the cache entry.put
in interface CacheMap
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keycMillis
- the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass CacheMap.EXPIRY_DEFAULT
to use the cache's default time-to-live setting; pass CacheMap.EXPIRY_NEVER
to indicate that the cache entry should never expire; this milliseconds value is not a date/time value, such as is returned from System.currentTimeMillis()public int getUnits()
Note: It is expected that the return type will be widened to a long in Coherence 4.
getUnits
in interface ConfigurableCacheMap
public int getHighUnits()
Note: It is expected that the return type will be widened to a long in Coherence 4.
getHighUnits
in interface ConfigurableCacheMap
public void setHighUnits(int cMax)
Note: It is expected that the parameter will be widened to a long in Coherence 4.
setHighUnits
in interface ConfigurableCacheMap
cMax
- the new maximum size of the cache, in unitspublic int getLowUnits()
Note: It is expected that the parameter will be widened to a long in Coherence 4.
getLowUnits
in interface ConfigurableCacheMap
public void setLowUnits(int cUnits)
Note: It is expected that the parameter will be widened to a long in Coherence 4.
setLowUnits
in interface ConfigurableCacheMap
cUnits
- the number of units that the cache prunes topublic int getUnitFactor()
Note: This property exists only to avoid changing the type of the units, low units and high units properties from 32-bit values to 64-bit values. It is expected that the parameter will be dropped in Coherence 4.
getUnitFactor
in interface ConfigurableCacheMap
public void setUnitFactor(int nFactor)
Note: This property exists only to avoid changing the type of the units, low units and high units properties from 32-bit values to 64-bit values. It is expected that the parameter will be dropped in Coherence 4.
setUnitFactor
in interface ConfigurableCacheMap
nFactor
- the units factor; the default is 1public ConfigurableCacheMap.EvictionPolicy getEvictionPolicy()
getEvictionPolicy
in interface ConfigurableCacheMap
public void setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
setEvictionPolicy
in interface ConfigurableCacheMap
policy
- an EvictionPolicypublic void evict(java.lang.Object oKey)
evict
in interface ConfigurableCacheMap
oKey
- the key to evict from the cachepublic void evictAll(java.util.Collection colKeys)
The result of this method is defined to be semantically the same as the following implementation:
for (Iterator iter = colKeys.iterator(); iter.hasNext(); ) { Object oKey = iter.next(); evict(oKey); }
evictAll
in interface ConfigurableCacheMap
colKeys
- a collection of keys to evict from the cachepublic void evict()
evict
in interface ConfigurableCacheMap
evict
in class AbstractSerializationCache
public int getExpiryDelay()
getExpiryDelay
in interface ConfigurableCacheMap
public void setExpiryDelay(int cMillis)
setExpiryDelay
in interface ConfigurableCacheMap
cMillis
- the number of milliseconds that cache entries will live, or zero to disable automatic expirypublic int getFlushDelay()
This value is used by cache implementations that periodically evict entries that have expired; this value has no meaning for cache implementations that aggressively evict entries as they expire.
getFlushDelay
in interface ConfigurableCacheMap
public void setFlushDelay(int cMillis)
This value is used by cache implementations that periodically evict entries that have expired; this value has no meaning for cache implementations that aggressively evict entries as they expire.
setFlushDelay
in interface ConfigurableCacheMap
cMillis
- the number of milliseconds between cache flushes, or zero to never flushpublic ConfigurableCacheMap.Entry getCacheEntry(java.lang.Object oKey)
getCacheEntry
in interface ConfigurableCacheMap
oKey
- the key object to search forpublic ConfigurableCacheMap.UnitCalculator getUnitCalculator()
getUnitCalculator
in interface ConfigurableCacheMap
public void setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
setUnitCalculator
in interface ConfigurableCacheMap
calculator
- a UnitCalculatorpublic void flush()
evict()
public java.lang.String toString()
toString
in class SerializationMap
protected void setBinaryStore(BinaryStore store)
setBinaryStore
in class SerializationMap
store
- the BinaryStore to usepublic int getMaximumSize()
getHighUnits()
public void setMaximumSize(int cMax)
setHighUnits(int)
cMax
- the new maximum number of entries that the cache will holdprotected long getTouchCounter()
protected LongArray getLruArray()
protected LongArray getExpiryArray()
protected java.lang.String getDescription()
getDescription
in class AbstractSerializationCache
protected void registerKey(java.lang.Object oKey, Binary binKey, Binary binValue)
registerKey
in class SerializationMap
oKey
- the key that has been added to the mapbinKey
- the binary form of the keybinValue
- the binary form of the valueprotected void registerKey(java.lang.Object oKey, Binary binKey, Binary binValue, int cMillis)
oKey
- the key that has been added to the mapbinKey
- the binary form of the key (null if only TTL change)binValue
- the binary form of the value (null if only TTL change)cMillis
- the TTL value (in milliseconds) for the entryprotected void touch(java.lang.Object oKey)
oKey
- the key of the object to touchprotected void unregisterKey(java.lang.Object oKey)
unregisterKey
in class SerializationMap
oKey
- the key that has been removed from the mapprotected void checkSize()
protected void checkExpiry()
public SerializationCache.EntryAttributes instantiateEntryAttributes(SerializationCache.EntryAttributes attrOrig, long ldtExpires, long nTouch, int cUnits)
attrOrig
- the previous attributes for this entry, if anyldtExpires
- the date/time at which the entry expires, or zeronTouch
- the touch counter assigned to the entrycUnits
- the number of storage units used by the entryprotected java.util.Set instantiateEntrySet()
instantiateEntrySet
in class AbstractKeySetBasedMap
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |