Class OldCache
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- com.tangosol.util.SafeHashMap
-
- com.tangosol.net.cache.OldCache
-
- All Implemented Interfaces:
CacheMap
,ConfigurableCacheMap
,ObservableMap
,Serializable
,Cloneable
,Map
- Direct Known Subclasses:
LocalCache
public class OldCache extends SafeHashMap implements ObservableMap, ConfigurableCacheMap
Deprecated.As of Coherence 3.1, useLocalCache
insteadA generic cache manager.The implementation is thread safe and uses a combination of Most Recently Used (MRU) and Most Frequently Used (MFU) caching strategies.
The cache is size-limited, which means that once it reaches its maximum size ("high-water mark") it prunes itself (to its "low-water mark"). The cache high- and low-water-marks are measured in terms of "units", and each cached item by default uses one unit. All of the cache constructors, except for the default constructor, require the maximum number of units to be passed in. To change the number of units that each cache entry uses, either set the Units property of the cache entry, or extend the Cache implementation so that the inner Entry class calculates its own unit size. To determine the current, high-water and low-water sizes of the cache, use the cache object's Units, HighUnits and LowUnits properties. The HighUnits and LowUnits properties can be changed, even after the cache is in use. To specify the LowUnits value as a percentage when constructing the cache, use the extended constructor taking the percentage-prune-level.
Each cached entry expires after one hour by default. To alter this behavior, use a constructor that takes the expiry-millis; for example, an expiry-millis value of 10000 will expire entries after 10 seconds. The ExpiryDelay property can also be set once the cache is in use, but it will not affect the expiry of previously cached items.
Cache hit statistics can be obtained from the CacheHits, CacheMisses, HitProbability, KeyHitProbability and CompositeHitProbability read-only properties. The statistics can be reset by invoking resetHitStatistics. The statistics are automatically reset when the cache is cleared (the clear method).
The OldCache implements the ObservableMap interface, meaning it provides event notifications to any interested listener for each insert, update and delete, including those that occur when the cache is pruned or entries are automatically expired.
This implementation is designed to support extension through inheritance. When overriding the inner Entry class, the OldCache.instantiateEntry factory method must be overridden to instantiate the correct Entry sub-class. To override the one-unit-per-entry default behavior, extend the inner Entry class and override the calculateUnits method.
- Author:
- cp 2001.04.19, cp 2005.05.18 moved to com.tangosol.net.cache package
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OldCache.Entry
Deprecated.A holder for a cached value.protected class
OldCache.EntrySet
Deprecated.A set of entries backed by this map.static interface
OldCache.EvictionPolicy
Deprecated.An eviction policy is an object that the cache provides with access information, and when requested, the eviction policy selects and evicts entries from the cache.static class
OldCache.InternalEvictionPolicy
Deprecated.The InternalEvictionPolicy represents a pluggable eviction policy for the non-pluggable built-in (internal) eviction policies supported by this cache implementation.static class
OldCache.InternalUnitCalculator
Deprecated.The InternalUnitCalculator represents a pluggable UnitCalculator for the non-pluggable built-in (internal) UnitCalculator implementation provided by this cache implementation.protected class
OldCache.KeySet
Deprecated.A set of entries backed by this map.static interface
OldCache.UnitCalculator
Deprecated.A unit calculator is an object that can calculate the cost of caching an object.protected class
OldCache.ValuesCollection
Deprecated.A collection of values backed by this map.-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
Nested classes/interfaces inherited from interface com.tangosol.net.cache.ConfigurableCacheMap
ConfigurableCacheMap.EvictionApprover
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_EXPIRE
Deprecated.By default, the cache entries expire after one hour.static int
DEFAULT_FLUSH
Deprecated.as of Coherence 3.5static double
DEFAULT_PRUNE
Deprecated.By default, when the cache prunes, it reduces its entries to this percentage.static int
DEFAULT_UNITS
Deprecated.By default, the cache size (in units).static int
EVICTION_POLICY_EXTERNAL
Deprecated.The cache can prune using an external eviction policy.static int
EVICTION_POLICY_HYBRID
Deprecated.By default, the cache prunes based on a hybrid LRU+LFU algorithm.static int
EVICTION_POLICY_LFU
Deprecated.The cache can prune based on a pure Least Frequently Used (LFU) algorithm.static int
EVICTION_POLICY_LRU
Deprecated.The cache can prune based on a pure Least Recently Used (LRU) algorithm.static OldCache.UnitCalculator
INSTANCE_BINARY
Deprecated.The UnitCalculator object that measures the bytes used by entries.static OldCache.UnitCalculator
INSTANCE_FIXED
Deprecated.The UnitCalculator object that counts each entry as one unit.static OldCache.EvictionPolicy
INSTANCE_HYBRID
Deprecated.The EvictionPolicy object for the Hybrid eviction algorithm.static OldCache.EvictionPolicy
INSTANCE_LFU
Deprecated.The EvictionPolicy object for the Least Frequently Used (LFU) eviction algorithm.static OldCache.EvictionPolicy
INSTANCE_LRU
Deprecated.The EvictionPolicy object for the Least Recently Used (LRU) eviction algorithm.protected ConfigurableCacheMap.EvictionApprover
m_apprvrEvict
Deprecated.The EvictionApprover.protected LongArray
m_arrayExpiry
Deprecated.Array of set of keys, indexed by the time of expiry.protected ConfigurableCacheMap.UnitCalculator
m_calculator
Deprecated.The external unit calculator.protected int
m_cAvgTouch
Deprecated.For a prune cycle, this value is the average number of touches that an entry should have.protected long
m_cCurUnits
Deprecated.The current number of units in the cache.protected int
m_cExpiryDelay
Deprecated.The number of milliseconds that a value will live in the cache.protected long
m_cMaxUnits
Deprecated.The number of units to allow the cache to grow to before pruning.protected long
m_cPruneUnits
Deprecated.The number of units to prune the cache down to.protected double
m_dflPruneLevel
Deprecated.The percentage of the total number of units that will remain after the cache manager prunes the cache (i.e. this is the "low water mark" value); this value is in the range 0.0 to 1.0.protected boolean
m_fIncrementalEvict
Deprecated.Specifies whether or not this cache will incrementally evict.protected boolean
m_fOptimizeGetTime
Deprecated.Specifies whether or not this cache is used in the environment, where theBase.getSafeTimeMillis()
is used very frequently and as a result, theBase.getLastSafeTimeMillis()
could be used without sacrificing the clock precision.protected ListIterator
m_iterEvict
Deprecated.For deferred eviction, iterator of entries to evict.protected MapListenerSupport
m_listenerSupport
Deprecated.The MapListenerSupport object.protected long
m_lLastPrune
Deprecated.The last time that a prune was run.protected long
m_lNextFlush
Deprecated.The time before which a expired-entries flush will not be performed.protected int
m_nCalculatorType
Deprecated.The type of unit calculator employed by the cache; one of the UNIT_CALCULATOR_* enumerated values.protected int
m_nEvictionType
Deprecated.The type of eviction policy employed by the cache; one of the EVICTION_POLICY_* enumerated values.protected int
m_nUnitFactor
Deprecated.The unit factor.protected ConfigurableCacheMap.EvictionPolicy
m_policy
Deprecated.The eviction policy; for eviction type EVICTION_POLICY_EXTERNAL.protected SimpleCacheStatistics
m_stats
Deprecated.The CacheStatistics object maintained by this cache.static int
UNIT_CALCULATOR_BINARY
Deprecated.Specifies a unit calculator that assigns an object a weight equal to the number of bytes of memory required to cache the object.static int
UNIT_CALCULATOR_EXTERNAL
Deprecated.Specifies a external (custom) unit calculator implementation.static int
UNIT_CALCULATOR_FIXED
Deprecated.Specifies the default unit calculator that weighs all entries equally as 1.-
Fields inherited from class com.tangosol.util.SafeHashMap
BIGGEST_MODULO, DEFAULT_GROWTHRATE, DEFAULT_INITIALSIZE, DEFAULT_LOADFACTOR, m_aeBucket, m_cCapacity, m_cEntries, m_colValues, m_flGrowthRate, m_flLoadFactor, m_oIterActive, m_setEntries, m_setKeys, RESIZING
-
Fields inherited from interface com.tangosol.net.cache.CacheMap
EXPIRY_DEFAULT, EXPIRY_NEVER
-
-
Constructor Summary
Constructors Constructor Description OldCache()
Deprecated.Construct the cache manager.OldCache(int cUnits)
Deprecated.Construct the cache manager.OldCache(int cUnits, int cExpiryMillis)
Deprecated.Construct the cache manager.OldCache(int cUnits, int cExpiryMillis, double dflPruneLevel)
Deprecated.Construct the cache manager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addMapListener(MapListener listener)
Deprecated.Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included.void
addMapListener(MapListener listener, Filter filter, boolean fLite)
Deprecated.Add a map listener that receives events based on a filter evaluation.void
addMapListener(MapListener listener, Object oKey, boolean fLite)
Deprecated.Add a map listener for a specific key.protected void
adjustUnits(int cDelta)
Deprecated.Adjust current size.protected void
checkFlush()
Deprecated.as of Coherence 3.5, useevict()
void
clear()
Deprecated.Removes all mappings from this map.protected void
configureEviction(int nType, ConfigurableCacheMap.EvictionPolicy policy)
Deprecated.Configure the eviction type and policy.protected void
configureUnitCalculator(int nType, ConfigurableCacheMap.UnitCalculator calculator)
Deprecated.Configure the unit calculator type and implementation.boolean
containsKey(Object key)
Deprecated.Returns true if this map contains a mapping for the specified key.protected void
dispatchEvent(MapEvent evt)
Deprecated.Dispatch the passed event.void
evict()
Deprecated.Evict all entries from the cache that are no longer valid, and potentially prune the cache size if the cache is size-limited and its size is above the caching low water mark.void
evict(Object oKey)
Deprecated.Evict a specified key from the cache, as if it had expired from the cache.void
evictAll(Collection colKeys)
Deprecated.Evict the specified keys from the cache, as if they had each expired from the cache.Object
get(Object oKey)
Deprecated.Returns the value to which this map maps the specified key.Map
getAll(Collection colKeys)
Deprecated.Get all the specified keys, if they are in the cache.ConfigurableCacheMap.Entry
getCacheEntry(Object oKey)
Deprecated.Locate a cache Entry in the cache based on its key.long
getCacheHits()
Deprecated.Determine the rough number of cache hits since the cache statistics were last reset.long
getCacheMisses()
Deprecated.Determine the rough number of cache misses since the cache statistics were last reset.CacheStatistics
getCacheStatistics()
Deprecated.Returns the CacheStatistics for this cache.long
getCurrentTimeMillis()
Deprecated.Return the currentsafe time
orlast safe time
depending on the optimization flag.SafeHashMap.Entry
getEntry(Object oKey)
Deprecated.Locate an Entry in the hash map based on its key.protected SafeHashMap.Entry
getEntryInternal(Object oKey)
Deprecated.Locate an Entry in the hash map based on its key.ConfigurableCacheMap.EvictionApprover
getEvictionApprover()
Deprecated.Obtain the registered EvictionApprover.ConfigurableCacheMap.EvictionPolicy
getEvictionPolicy()
Deprecated.Obtain the current EvictionPolicy used by the cache.int
getEvictionType()
Deprecated.Determine the current eviction type.int
getExpiryDelay()
Deprecated.Determine the default "time to live" for each individual cache entry.long
getFlushTime()
Deprecated.as of Coherence 3.5int
getHighUnits()
Deprecated.Determine the limit of the cache size in units.double
getHitProbability()
Deprecated.Determine the rough probability (0 <= p <= 1) that any particularget(java.lang.Object)
invocation will be satisfied by an existing entry in the cache, based on the statistics collected since the last reset of the cache statistics.int
getLowUnits()
Deprecated.Determine the point to which the cache will shrink when it prunes.protected MapListenerSupport
getMapListenerSupport()
Deprecated.Accessor for the MapListenerSupport for sub-classes.long
getNextExpiryTime()
Deprecated.Determine the next expiry time for the cache entries.ConfigurableCacheMap.UnitCalculator
getUnitCalculator()
Deprecated.Obtain the current UnitCalculator used by the cache.int
getUnitCalculatorType()
Deprecated.Determine the current unit calculator type.int
getUnitFactor()
Deprecated.Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted.int
getUnits()
Deprecated.Determine the number of units that the cache currently stores.protected boolean
hasListeners()
Deprecated.Determine if the OldCache has any listeners at all.protected SafeHashMap.Entry
instantiateEntry()
Deprecated.Factory method.protected SafeHashMap.EntrySet
instantiateEntrySet()
Deprecated.Factory pattern.protected SafeHashMap.KeySet
instantiateKeySet()
Deprecated.Factory pattern.protected MapEvent
instantiateMapEvent(int nId, Object oKey, Object oValueOld, Object oValueNew)
Deprecated.Factory pattern: instantiate a new MapEvent corresponding to the specified parameters.protected SafeHashMap.ValuesCollection
instantiateValuesCollection()
Deprecated.Factory pattern.boolean
isEmpty()
Deprecated.Returns true if this map contains no key-value mappings.boolean
isIncrementalEviction()
Deprecated.Determine if incremental eviction is enabled.protected void
prune()
Deprecated.Prune the cache by discarding the lowest priority cache entries.Object
put(Object oKey, Object oValue)
Deprecated.Associates the specified value with the specified key in this map.Object
put(Object oKey, Object oValue, long cMillis)
Deprecated.Associates the specified value with the specified key in this cache.Object
remove(Object oKey)
Deprecated.Removes the mapping for this key from this map if present.protected boolean
removeEvicted(OldCache.Entry entry)
Deprecated.Remove an entry (if it is eligible for eviction) because it has expired.protected boolean
removeExpired(OldCache.Entry entry, boolean fRemoveInternal)
Deprecated.useremoveEvicted(Entry)
insteadprotected boolean
removeIfExpired(OldCache.Entry entry)
Deprecated.Remove an entry if it has expired.void
removeMapListener(MapListener listener)
Deprecated.Remove a standard map listener that previously signed up for all events.void
removeMapListener(MapListener listener, Filter filter)
Deprecated.Remove a map listener that previously signed up for events based on a filter evaluation.void
removeMapListener(MapListener listener, Object oKey)
Deprecated.Remove a map listener that previously signed up for events about a specific key.void
resetHitStatistics()
Deprecated.Reset the cache statistics.void
setEvictionApprover(ConfigurableCacheMap.EvictionApprover approver)
Deprecated.Set the EvictionApprover for this ConfigurableCacheMap.void
setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
Deprecated.Set the EvictionPolicy for the cache to use.void
setEvictionType(int nType)
Deprecated.Specify the eviction type for the cache.void
setExpiryDelay(int cMillis)
Deprecated.Specify the default "time to live" for cache entries.void
setFlushTime(long lMillis)
Deprecated.as of Coherence 3.5void
setHighUnits(int cMax)
Deprecated.Update the maximum size of the cache in units.void
setIncrementalEviction(boolean fIncrementalEvict)
Deprecated.Specify whether incremental eviction is enabled.void
setLowUnits(int cMin)
Deprecated.Specify the point to which the cache will shrink when it prunes.void
setOptimizeGetTime(boolean fOptimize)
Deprecated.Specify whether or not this cache is used in the environment, where theBase.getSafeTimeMillis()
is used very frequently and as a result, theBase.getLastSafeTimeMillis()
could be used without sacrificing the clock precision.void
setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
Deprecated.Set the UnitCalculator for the cache to use.void
setUnitCalculatorType(int nType)
Deprecated.Specify the unit calculator type for the cache.void
setUnitFactor(int nFactor)
Deprecated.Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted.int
size()
Deprecated.Returns the number of key-value mappings in this map.protected static int
toExternalUnits(long cUnits, int nFactor)
Deprecated.Convert from an internal 64-bit unit value to an external 32-bit unit value using the configured units factor.protected static long
toInternalUnits(int cUnits, int nFactor)
Deprecated.Convert from an external 32-bit unit value to an internal 64-bit unit value using the configured units factor.String
toString()
Deprecated.For debugging purposes, format the contents of the cache as a String.void
tryEvict()
Deprecated.Attempt to call evict() when no one else is, to avoid contention on opportunistic attempts at evicting.-
Methods inherited from class com.tangosol.util.SafeHashMap
clone, cloneEntryList, entrySet, getBucketIndex, getStableBucketArray, grow, instantiateEntry, isActiveIterator, iteratorActivated, iteratorDeactivated, keySet, removeEntryInternal, values
-
Methods inherited from class java.util.AbstractMap
containsValue, equals, hashCode, putAll
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, values
-
-
-
-
Field Detail
-
DEFAULT_UNITS
public static final int DEFAULT_UNITS
Deprecated.By default, the cache size (in units).- See Also:
- Constant Field Values
-
DEFAULT_EXPIRE
public static final int DEFAULT_EXPIRE
Deprecated.By default, the cache entries expire after one hour.- See Also:
- Constant Field Values
-
DEFAULT_FLUSH
public static final int DEFAULT_FLUSH
Deprecated.as of Coherence 3.5By default, expired cache entries are flushed on a minute interval.- See Also:
- Constant Field Values
-
DEFAULT_PRUNE
public static final double DEFAULT_PRUNE
Deprecated.By default, when the cache prunes, it reduces its entries to this percentage.- See Also:
- Constant Field Values
-
EVICTION_POLICY_HYBRID
public static final int EVICTION_POLICY_HYBRID
Deprecated.By default, the cache prunes based on a hybrid LRU+LFU algorithm.- See Also:
- Constant Field Values
-
EVICTION_POLICY_LRU
public static final int EVICTION_POLICY_LRU
Deprecated.The cache can prune based on a pure Least Recently Used (LRU) algorithm.- See Also:
- Constant Field Values
-
EVICTION_POLICY_LFU
public static final int EVICTION_POLICY_LFU
Deprecated.The cache can prune based on a pure Least Frequently Used (LFU) algorithm.- See Also:
- Constant Field Values
-
EVICTION_POLICY_EXTERNAL
public static final int EVICTION_POLICY_EXTERNAL
Deprecated.The cache can prune using an external eviction policy.- See Also:
- Constant Field Values
-
UNIT_CALCULATOR_FIXED
public static final int UNIT_CALCULATOR_FIXED
Deprecated.Specifies the default unit calculator that weighs all entries equally as 1.- See Also:
- Constant Field Values
-
UNIT_CALCULATOR_BINARY
public static final int UNIT_CALCULATOR_BINARY
Deprecated.Specifies a unit calculator that assigns an object a weight equal to the number of bytes of memory required to cache the object.- See Also:
BinaryMemoryCalculator
, Constant Field Values
-
UNIT_CALCULATOR_EXTERNAL
public static final int UNIT_CALCULATOR_EXTERNAL
Deprecated.Specifies a external (custom) unit calculator implementation.- See Also:
- Constant Field Values
-
INSTANCE_HYBRID
public static final OldCache.EvictionPolicy INSTANCE_HYBRID
Deprecated.The EvictionPolicy object for the Hybrid eviction algorithm.
-
INSTANCE_LRU
public static final OldCache.EvictionPolicy INSTANCE_LRU
Deprecated.The EvictionPolicy object for the Least Recently Used (LRU) eviction algorithm.
-
INSTANCE_LFU
public static final OldCache.EvictionPolicy INSTANCE_LFU
Deprecated.The EvictionPolicy object for the Least Frequently Used (LFU) eviction algorithm.
-
INSTANCE_FIXED
public static final OldCache.UnitCalculator INSTANCE_FIXED
Deprecated.The UnitCalculator object that counts each entry as one unit.
-
INSTANCE_BINARY
public static final OldCache.UnitCalculator INSTANCE_BINARY
Deprecated.The UnitCalculator object that measures the bytes used by entries. This is intended for caches that manage binary data.
-
m_cCurUnits
protected volatile long m_cCurUnits
Deprecated.The current number of units in the cache. A unit is an undefined means of measuring cached values, and must be 0 or positive. The particular Entry implementation being used defines the meaning of unit.
-
m_cMaxUnits
protected long m_cMaxUnits
Deprecated.The number of units to allow the cache to grow to before pruning.
-
m_dflPruneLevel
protected double m_dflPruneLevel
Deprecated.The percentage of the total number of units that will remain after the cache manager prunes the cache (i.e. this is the "low water mark" value); this value is in the range 0.0 to 1.0.
-
m_cPruneUnits
protected long m_cPruneUnits
Deprecated.The number of units to prune the cache down to.
-
m_nUnitFactor
protected int m_nUnitFactor
Deprecated.The unit factor.
-
m_cExpiryDelay
protected int m_cExpiryDelay
Deprecated.The number of milliseconds that a value will live in the cache. Zero indicates no timeout.
-
m_lNextFlush
protected volatile long m_lNextFlush
Deprecated.The time before which a expired-entries flush will not be performed.
-
m_stats
protected SimpleCacheStatistics m_stats
Deprecated.The CacheStatistics object maintained by this cache.
-
m_listenerSupport
protected MapListenerSupport m_listenerSupport
Deprecated.The MapListenerSupport object.
-
m_nEvictionType
protected int m_nEvictionType
Deprecated.The type of eviction policy employed by the cache; one of the EVICTION_POLICY_* enumerated values.
-
m_policy
protected ConfigurableCacheMap.EvictionPolicy m_policy
Deprecated.The eviction policy; for eviction type EVICTION_POLICY_EXTERNAL.
-
m_nCalculatorType
protected int m_nCalculatorType
Deprecated.The type of unit calculator employed by the cache; one of the UNIT_CALCULATOR_* enumerated values.
-
m_calculator
protected ConfigurableCacheMap.UnitCalculator m_calculator
Deprecated.The external unit calculator.
-
m_arrayExpiry
protected LongArray m_arrayExpiry
Deprecated.Array of set of keys, indexed by the time of expiry.- Since:
- Coherence 3.5
-
m_lLastPrune
protected long m_lLastPrune
Deprecated.The last time that a prune was run. This value is used by the hybrid eviction policy.- Since:
- Coherence 3.5
-
m_cAvgTouch
protected int m_cAvgTouch
Deprecated.For a prune cycle, this value is the average number of touches that an entry should have. This value is used by the hybrid eviction policy.- Since:
- Coherence 3.5
-
m_iterEvict
protected ListIterator m_iterEvict
Deprecated.For deferred eviction, iterator of entries to evict. If null, then there are no entries with deferred eviction.- Since:
- Coherence 3.5
-
m_fIncrementalEvict
protected boolean m_fIncrementalEvict
Deprecated.Specifies whether or not this cache will incrementally evict.
-
m_apprvrEvict
protected volatile ConfigurableCacheMap.EvictionApprover m_apprvrEvict
Deprecated.The EvictionApprover.
-
m_fOptimizeGetTime
protected boolean m_fOptimizeGetTime
Deprecated.Specifies whether or not this cache is used in the environment, where theBase.getSafeTimeMillis()
is used very frequently and as a result, theBase.getLastSafeTimeMillis()
could be used without sacrificing the clock precision. By default, the optimization is off.
-
-
Constructor Detail
-
OldCache
public OldCache()
Deprecated.Construct the cache manager.
-
OldCache
public OldCache(int cUnits)
Deprecated.Construct the cache manager.- Parameters:
cUnits
- the number of units that the cache manager will cache before pruning the cache
-
OldCache
public OldCache(int cUnits, int cExpiryMillis)
Deprecated.Construct the cache manager.- Parameters:
cUnits
- the number of units that the cache manager will cache before pruning the cachecExpiryMillis
- the number of milliseconds that each cache entry lives before being automatically expired
-
OldCache
public OldCache(int cUnits, int cExpiryMillis, double dflPruneLevel)
Deprecated.Construct the cache manager.- Parameters:
cUnits
- the number of units that the cache manager will cache before pruning the cachecExpiryMillis
- the number of milliseconds that each cache entry lives before being automatically expireddflPruneLevel
- the percentage of the total number of units that will remain after the cache manager prunes the cache (i.e. this is the "low water mark" value); this value is in the range 0.0 to 1.0
-
-
Method Detail
-
size
public int size()
Deprecated.Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.This method is not synchronized; it returns the size at the moment that the method is invoked. To ensure that the size does not change from the returned value, the caller must synchronize on the map before calling the size method.
- Specified by:
size
in interfaceMap
- Overrides:
size
in classSafeHashMap
- Returns:
- the number of key-value mappings in this map
-
isEmpty
public boolean isEmpty()
Deprecated.Returns true if this map contains no key-value mappings.This method is not synchronized; it returns the state of the map at the moment that the method is invoked. To ensure that the size does not change, the caller must synchronize on the map before calling the method.
- Specified by:
isEmpty
in interfaceMap
- Overrides:
isEmpty
in classSafeHashMap
- Returns:
- true if this map contains no key-value mappings
-
containsKey
public boolean containsKey(Object key)
Deprecated.Returns true if this map contains a mapping for the specified key.This method is not synchronized; it returns true if the map contains the key at the moment that the method is invoked. To ensure that the key is still in (or is still not in) the table when the method returns, the caller must synchronize on the map before calling the method.
- Specified by:
containsKey
in interfaceMap
- Overrides:
containsKey
in classSafeHashMap
- Parameters:
key
- key whose presence in this map is to be tested- Returns:
- true if this map contains a mapping for the specified key
-
get
public Object get(Object oKey)
Deprecated.Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.- Specified by:
get
in interfaceMap
- Overrides:
get
in classSafeHashMap
- Parameters:
oKey
- key whose associated value is to be returned- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key
-
getEntry
public SafeHashMap.Entry getEntry(Object oKey)
Deprecated.Locate an Entry in the hash map based on its key.- Overrides:
getEntry
in classSafeHashMap
- Parameters:
oKey
- the key object to search for- Returns:
- the Entry or null
-
getCacheEntry
public ConfigurableCacheMap.Entry getCacheEntry(Object oKey)
Deprecated.Locate a cache Entry in the cache based on its key.- Specified by:
getCacheEntry
in interfaceConfigurableCacheMap
- Parameters:
oKey
- the key object to search for- Returns:
- the Entry or null
-
put
public Object put(Object oKey, Object oValue)
Deprecated.Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.This method is not synchronized; it only synchronizes internally if it has to add a new Entry. To ensure that the value does not change (or the Entry is not removed) before this method returns, the caller must synchronize on the map before calling this method.
- Specified by:
put
in interfaceCacheMap
- Specified by:
put
in interfaceMap
- Overrides:
put
in classSafeHashMap
- Parameters:
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
-
put
public Object put(Object oKey, Object oValue, long cMillis)
Deprecated.Associates the specified value with the specified key in this cache. If the cache previously contained a mapping for this key, the old value is replaced. This variation of theCacheMap.put(Object oKey, Object oValue)
method allows the caller to specify an expiry (or "time to live") for the cache entry.- Specified by:
put
in interfaceCacheMap
- Parameters:
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"; passCacheMap.EXPIRY_DEFAULT
to use the cache's default time-to-live setting; passCacheMap.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()- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
-
remove
public Object remove(Object oKey)
Deprecated.Removes the mapping for this key from this map if present.- Specified by:
remove
in interfaceMap
- Overrides:
remove
in classSafeHashMap
- Parameters:
oKey
- key whose mapping is to be removed from the map- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
-
clear
public void clear()
Deprecated.Removes all mappings from this map.- Specified by:
clear
in interfaceMap
- Overrides:
clear
in classSafeHashMap
-
addMapListener
public void addMapListener(MapListener listener)
Deprecated.Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included. This has the same result as the following call:addMapListener(listener, (Filter) null, false);
- Specified by:
addMapListener
in interfaceObservableMap
- Parameters:
listener
- theMapEvent
listener to add
-
removeMapListener
public void removeMapListener(MapListener listener)
Deprecated.Remove a standard map listener that previously signed up for all events. This has the same result as the following call:removeMapListener(listener, (Filter) null);
- Specified by:
removeMapListener
in interfaceObservableMap
- Parameters:
listener
- the listener to remove
-
addMapListener
public void addMapListener(MapListener listener, Object oKey, boolean fLite)
Deprecated.Add a map listener for a specific key.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the
ObservableMap.removeMapListener(MapListener, Object)
method.- Specified by:
addMapListener
in interfaceObservableMap
- Parameters:
listener
- theMapEvent
listener to addoKey
- the key that identifies the entry for which to raise eventsfLite
- true to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
public void removeMapListener(MapListener listener, Object oKey)
Deprecated.Remove a map listener that previously signed up for events about a specific key.- Specified by:
removeMapListener
in interfaceObservableMap
- Parameters:
listener
- the listener to removeoKey
- the key that identifies the entry for which to raise events
-
addMapListener
public void addMapListener(MapListener listener, Filter filter, boolean fLite)
Deprecated.Add a map listener that receives events based on a filter evaluation.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the
ObservableMap.removeMapListener(MapListener, Filter)
method.- Specified by:
addMapListener
in interfaceObservableMap
- Parameters:
listener
- theMapEvent
listener to addfilter
- a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent (seeMapEventFilter
); null is equivalent to a filter that alway returns truefLite
- true to indicate that theMapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizations
-
removeMapListener
public void removeMapListener(MapListener listener, Filter filter)
Deprecated.Remove a map listener that previously signed up for events based on a filter evaluation.- Specified by:
removeMapListener
in interfaceObservableMap
- Parameters:
listener
- the listener to removefilter
- the filter that was passed into the corresponding addMapListener() call
-
getAll
public Map getAll(Collection colKeys)
Deprecated.Get all the specified keys, if they are in the cache. For each key that is in the cache, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the cache, which may imply (for caches that can load behind the scenes) that the requested data could not be loaded.The result of this method is defined to be semantically the same as the following implementation, without regards to threading issues:
Map map = new AnyMap(); // could be a HashMap (but does not have to) for (Iterator iter = colKeys.iterator(); iter.hasNext(); ) { Object oKey = iter.next(); Object oVal = get(oKey); if (oVal != null || containsKey(oKey)) { map.put(oKey, oVal); } } return map;
-
evict
public void evict(Object oKey)
Deprecated.Evict a specified key from the cache, as if it had expired from the cache. If the key is not in the cache or the entry is not eligible for eviction, then this method has no effect.- Specified by:
evict
in interfaceConfigurableCacheMap
- Parameters:
oKey
- the key to evict from the cache
-
evictAll
public void evictAll(Collection colKeys)
Deprecated.Evict the specified keys from the cache, as if they had each expired from the cache.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); }
- Specified by:
evictAll
in interfaceConfigurableCacheMap
- Parameters:
colKeys
- a collection of keys to evict from the cache
-
tryEvict
public void tryEvict()
Deprecated.Attempt to call evict() when no one else is, to avoid contention on opportunistic attempts at evicting.
-
evict
public void evict()
Deprecated.Evict all entries from the cache that are no longer valid, and potentially prune the cache size if the cache is size-limited and its size is above the caching low water mark.- Specified by:
evict
in interfaceConfigurableCacheMap
-
getCacheStatistics
public CacheStatistics getCacheStatistics()
Deprecated.Returns the CacheStatistics for this cache.- Returns:
- a CacheStatistics object
-
instantiateEntrySet
protected SafeHashMap.EntrySet instantiateEntrySet()
Deprecated.Factory pattern.- Overrides:
instantiateEntrySet
in classSafeHashMap
- Returns:
- a new instance of the EntrySet class (or a subclass thereof)
-
instantiateKeySet
protected SafeHashMap.KeySet instantiateKeySet()
Deprecated.Factory pattern.- Overrides:
instantiateKeySet
in classSafeHashMap
- Returns:
- a new instance of the KeySet class (or subclass thereof)
-
instantiateValuesCollection
protected SafeHashMap.ValuesCollection instantiateValuesCollection()
Deprecated.Factory pattern.- Overrides:
instantiateValuesCollection
in classSafeHashMap
- Returns:
- a new instance of the ValuesCollection class (or subclass thereof)
-
toString
public String toString()
Deprecated.For debugging purposes, format the contents of the cache as a String.- Overrides:
toString
in classAbstractMap
- Returns:
- a String representation of the cache contents
-
getUnits
public int getUnits()
Deprecated.Determine the number of units that the cache currently stores.Note: It is expected that the return type will be widened to a long in Coherence 4.
- Specified by:
getUnits
in interfaceConfigurableCacheMap
- Returns:
- the current size of the cache in units
-
getHighUnits
public int getHighUnits()
Deprecated.Determine the limit of the cache size in units. The cache will prune itself automatically once it reaches its maximum unit level. This is often referred to as the "high water mark" of the cache.Note: It is expected that the return type will be widened to a long in Coherence 4.
- Specified by:
getHighUnits
in interfaceConfigurableCacheMap
- Returns:
- the limit of the cache size in units
-
setHighUnits
public void setHighUnits(int cMax)
Deprecated.Update the maximum size of the cache in units. This is often referred to as the "high water mark" of the cache.Note: It is expected that the parameter will be widened to a long in Coherence 4.
- Specified by:
setHighUnits
in interfaceConfigurableCacheMap
- Parameters:
cMax
- the new maximum size of the cache, in units
-
getLowUnits
public int getLowUnits()
Deprecated.Determine the point to which the cache will shrink when it prunes. This is often referred to as a "low water mark" of the cache. If the cache incrementally prunes, then this setting will have no effect.Note: It is expected that the parameter will be widened to a long in Coherence 4.
- Specified by:
getLowUnits
in interfaceConfigurableCacheMap
- Returns:
- the number of units that the cache prunes to
-
setLowUnits
public void setLowUnits(int cMin)
Deprecated.Specify the point to which the cache will shrink when it prunes. This is often referred to as a "low water mark" of the cache.Note: It is expected that the parameter will be widened to a long in Coherence 4.
- Specified by:
setLowUnits
in interfaceConfigurableCacheMap
- Parameters:
cMin
- the number of units that the cache prunes to
-
getUnitFactor
public int getUnitFactor()
Deprecated.Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted. Using a binary unit calculator, for example, the factor 1048576 could be used to count megabytes instead of bytes.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.
- Specified by:
getUnitFactor
in interfaceConfigurableCacheMap
- Returns:
- the units factor; the default is 1
-
setUnitFactor
public void setUnitFactor(int nFactor)
Deprecated.Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted. Using a binary unit calculator, for example, the factor 1048576 could be used to count megabytes instead of bytes.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.
- Specified by:
setUnitFactor
in interfaceConfigurableCacheMap
- Parameters:
nFactor
- the units factor; the default is 1
-
toInternalUnits
protected static long toInternalUnits(int cUnits, int nFactor)
Deprecated.Convert from an external 32-bit unit value to an internal 64-bit unit value using the configured units factor.- Parameters:
cUnits
- an external 32-bit units valuenFactor
- the unit factor- Returns:
- an internal 64-bit units value
-
toExternalUnits
protected static int toExternalUnits(long cUnits, int nFactor)
Deprecated.Convert from an internal 64-bit unit value to an external 32-bit unit value using the configured units factor.- Parameters:
cUnits
- an internal 64-bit units valuenFactor
- the unit factor- Returns:
- an external 32-bit units value
-
getEvictionType
public int getEvictionType()
Deprecated.Determine the current eviction type.- Returns:
- one of the EVICTION_POLICY_* enumerated values
-
setEvictionType
public void setEvictionType(int nType)
Deprecated.Specify the eviction type for the cache. The type can only be set to an external policy if an EvictionPolicy object has been provided.- Parameters:
nType
- one of the EVICTION_POLICY_* enumerated values
-
getEvictionPolicy
public ConfigurableCacheMap.EvictionPolicy getEvictionPolicy()
Deprecated.Obtain the current EvictionPolicy used by the cache.- Specified by:
getEvictionPolicy
in interfaceConfigurableCacheMap
- Returns:
- the EvictionPolicy used by the cache
-
setEvictionPolicy
public void setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
Deprecated.Set the EvictionPolicy for the cache to use.- Specified by:
setEvictionPolicy
in interfaceConfigurableCacheMap
- Parameters:
policy
- an EvictionPolicy
-
getEvictionApprover
public ConfigurableCacheMap.EvictionApprover getEvictionApprover()
Deprecated.Obtain the registered EvictionApprover.- Specified by:
getEvictionApprover
in interfaceConfigurableCacheMap
- Returns:
- the EvictionApprover (could be null)
-
setEvictionApprover
public void setEvictionApprover(ConfigurableCacheMap.EvictionApprover approver)
Deprecated.Set the EvictionApprover for this ConfigurableCacheMap.- Specified by:
setEvictionApprover
in interfaceConfigurableCacheMap
- Parameters:
approver
- the EvictionApprover
-
getUnitCalculatorType
public int getUnitCalculatorType()
Deprecated.Determine the current unit calculator type.- Returns:
- one of the UNIT_CALCULATOR_* enumerated values
-
setUnitCalculatorType
public void setUnitCalculatorType(int nType)
Deprecated.Specify the unit calculator type for the cache. The type can only be set to an external unit calculator if a UnitCalculator object has been provided.- Parameters:
nType
- one of the UNIT_CALCULATOR_* enumerated values
-
getUnitCalculator
public ConfigurableCacheMap.UnitCalculator getUnitCalculator()
Deprecated.Obtain the current UnitCalculator used by the cache.- Specified by:
getUnitCalculator
in interfaceConfigurableCacheMap
- Returns:
- the UnitCalculator used by the cache
-
setUnitCalculator
public void setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
Deprecated.Set the UnitCalculator for the cache to use.- Specified by:
setUnitCalculator
in interfaceConfigurableCacheMap
- Parameters:
calculator
- a UnitCalculator
-
getExpiryDelay
public int getExpiryDelay()
Deprecated.Determine the default "time to live" for each individual cache entry.- Specified by:
getExpiryDelay
in interfaceConfigurableCacheMap
- Returns:
- the number of milliseconds that a cache entry value will live, or zero if cache entries are never automatically expired
-
setExpiryDelay
public void setExpiryDelay(int cMillis)
Deprecated.Specify the default "time to live" for cache entries. This does not affect the already-scheduled expiry of existing entries.- Specified by:
setExpiryDelay
in interfaceConfigurableCacheMap
- Parameters:
cMillis
- the number of milliseconds that cache entries will live, or zero to disable automatic expiry
-
getNextExpiryTime
public long getNextExpiryTime()
Deprecated.Determine the next expiry time for the cache entries. This value is supposed to be used only by the "active" expiry algorithms, so for implementations that choose to return the value of zero the entries will be evicted as with pre-existing "passive" expiry approach.- Specified by:
getNextExpiryTime
in interfaceConfigurableCacheMap
- Returns:
- the earliest time (using the
SafeClock
) that one or more cache entries will expire or zero if the cache is empty, its entries never expire or the implementation chooses to avoid the pro-active eviction
-
getFlushTime
public long getFlushTime()
Deprecated.as of Coherence 3.5Determine the date/time at which the next cache flush is scheduled. Note that the date/time may be Long.MAX_VALUE, which implies that a flush will never occur. Also note that the cache may internally adjust the flush time to prevent a flush from occurring during certain processing as a means to raise concurrency.- Returns:
- the date/time value, in milliseconds, when the cache will next automatically flush
-
setFlushTime
public void setFlushTime(long lMillis)
Deprecated.as of Coherence 3.5Specify the date/time at which the next cache flush is to occur. Note that the date/time may be Long.MAX_VALUE, which implies that a flush will never occur. A time in the past or at the present will cause an immediate flush.- Parameters:
lMillis
- the date/time value, in milliseconds, when the cache should next automatically flush
-
isIncrementalEviction
public boolean isIncrementalEviction()
Deprecated.Determine if incremental eviction is enabled. (Incremental eviction is not supported for custom eviction policies.)- Returns:
- true if eviction is incremental; false if it is done in bulk
- Since:
- Coherence 3.5
-
setIncrementalEviction
public void setIncrementalEviction(boolean fIncrementalEvict)
Deprecated.Specify whether incremental eviction is enabled.- Parameters:
fIncrementalEvict
- pass true to enable incremental eviction; false to disable incremental eviction- Since:
- Coherence 3.5
-
getCacheHits
public long getCacheHits()
Deprecated.Determine the rough number of cache hits since the cache statistics were last reset.- Returns:
- the number of
get(java.lang.Object)
calls that have been served by existing cache entries
-
getCacheMisses
public long getCacheMisses()
Deprecated.Determine the rough number of cache misses since the cache statistics were last reset.- Returns:
- the number of
get(java.lang.Object)
calls that failed to find an existing cache entry because the requested key was not in the cache
-
getHitProbability
public double getHitProbability()
Deprecated.Determine the rough probability (0 <= p <= 1) that any particularget(java.lang.Object)
invocation will be satisfied by an existing entry in the cache, based on the statistics collected since the last reset of the cache statistics.- Returns:
- the cache hit probability (0 <= p <= 1)
-
resetHitStatistics
public void resetHitStatistics()
Deprecated.Reset the cache statistics.
-
configureEviction
protected void configureEviction(int nType, ConfigurableCacheMap.EvictionPolicy policy)
Deprecated.Configure the eviction type and policy.- Parameters:
nType
- one of the EVICTION_POLICY_* enumerated valuespolicy
- an external eviction policy, or null
-
configureUnitCalculator
protected void configureUnitCalculator(int nType, ConfigurableCacheMap.UnitCalculator calculator)
Deprecated.Configure the unit calculator type and implementation.- Parameters:
nType
- one of the UNIT_CALCULATOR_* enumerated valuescalculator
- an external unit calculator, or null
-
getEntryInternal
protected SafeHashMap.Entry getEntryInternal(Object oKey)
Deprecated.Locate an Entry in the hash map based on its key. If the Entry has expired and is eligible for eviction, it is removed from the hash map.Unlike the
getEntry(java.lang.Object)
method, this method does not flush the cache (if necessary) or update cache statistics.- Overrides:
getEntryInternal
in classSafeHashMap
- Parameters:
oKey
- the key object to search for- Returns:
- the Entry or null if the entry is not found in the hash map or has expired
-
removeExpired
protected boolean removeExpired(OldCache.Entry entry, boolean fRemoveInternal)
Deprecated.useremoveEvicted(Entry)
insteadRemove an entry (if it is eligible for eviction) because it has expired.Note: This method is the same as
removeEvicted(Entry)
and is left for backward compatibility.- Parameters:
entry
- the expired cache entryfRemoveInternal
- true if the cache entry still needs to be removed from the cache- Returns:
- true iff the entry was removed
-
removeEvicted
protected boolean removeEvicted(OldCache.Entry entry)
Deprecated.Remove an entry (if it is eligible for eviction) because it has expired.- Parameters:
entry
- the expired cache entry- Returns:
- true iff the entry was removed
-
removeIfExpired
protected boolean removeIfExpired(OldCache.Entry entry)
Deprecated.Remove an entry if it has expired.- Parameters:
entry
- the entry- Returns:
- true iff the entry was actually removed
-
adjustUnits
protected void adjustUnits(int cDelta)
Deprecated.Adjust current size.- Parameters:
cDelta
- the delta units to adjust to
-
prune
protected void prune()
Deprecated.Prune the cache by discarding the lowest priority cache entries.
-
checkFlush
protected void checkFlush()
Deprecated.as of Coherence 3.5, useevict()
Check if any entries in the cache have expired, and evict them if they have.
-
instantiateMapEvent
protected MapEvent instantiateMapEvent(int nId, Object oKey, Object oValueOld, Object oValueNew)
Deprecated.Factory pattern: instantiate a new MapEvent corresponding to the specified parameters.- Parameters:
nId
- the event IdoKey
- the keyoValueOld
- the old valueoValueNew
- the new value- Returns:
- a new instance of the MapEvent class (or a subclass thereof)
-
getMapListenerSupport
protected MapListenerSupport getMapListenerSupport()
Deprecated.Accessor for the MapListenerSupport for sub-classes.- Returns:
- the MapListenerSupport, or null if there are no listeners
-
hasListeners
protected boolean hasListeners()
Deprecated.Determine if the OldCache has any listeners at all.- Returns:
- true iff this OldCache has at least one MapListener
-
dispatchEvent
protected void dispatchEvent(MapEvent evt)
Deprecated.Dispatch the passed event.- Parameters:
evt
- a CacheEvent object
-
getCurrentTimeMillis
public long getCurrentTimeMillis()
Deprecated.Return the currentsafe time
orlast safe time
depending on the optimization flag.- Returns:
- the current time
-
setOptimizeGetTime
public void setOptimizeGetTime(boolean fOptimize)
Deprecated.Specify whether or not this cache is used in the environment, where theBase.getSafeTimeMillis()
is used very frequently and as a result, theBase.getLastSafeTimeMillis()
could be used without sacrificing the clock precision. By default, the optimization is off.- Parameters:
fOptimize
- pass true to turn the "last safe time" optimization on
-
instantiateEntry
protected SafeHashMap.Entry instantiateEntry()
Deprecated.Factory method. This method exists to allow the OldCache class to be easily inherited from by allowing the Entry class to be easily sub-classed.- Overrides:
instantiateEntry
in classSafeHashMap
- Returns:
- an instance of Entry that holds the passed cache value
-
-