Class SoftReferenceMemoryCache<K,V>
java.lang.Object
org.apache.commons.jcs3.engine.memory.AbstractMemoryCache<K,V>
org.apache.commons.jcs3.engine.memory.soft.SoftReferenceMemoryCache<K,V>
- All Implemented Interfaces:
IMemoryCache<K,
V>
A JCS IMemoryCache that has
SoftReference
to all its values.
This cache does not respect ICompositeCacheAttributes.getMaxObjects()
as overflowing is handled by Java GC.
The cache also has strong references to a maximum number of objects given by the maxObjects parameter
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionChildren must implement this method.int
freeElements
(int numberToFree) This can't be implemented.Get an Array of the keys for all elements in the memory cacheint
getSize()
Returns the current cache size.Returns the historical and statistical data for a region's memory cache.void
initialize
(CompositeCache<K, V> hub) For post reflection creation initializationprotected void
Update control structures after get (guarded by the lock)protected void
Removes all cached items from the cache control structures.protected void
Remove element from control structure (guarded by the lock)void
update
(ICacheElement<K, V> ce) Puts an item to the cache.Methods inherited from class org.apache.commons.jcs3.engine.memory.AbstractMemoryCache
dispose, dumpMap, get, getCacheAttributes, getCacheName, getCompositeCache, getMultiple, getQuiet, remove, removeAll, removeByGroup, removeByHierarchy, setCacheAttributes, waterfal
-
Constructor Details
-
SoftReferenceMemoryCache
public SoftReferenceMemoryCache()
-
-
Method Details
-
initialize
For post reflection creation initialization- Specified by:
initialize
in interfaceIMemoryCache<K,
V> - Overrides:
initialize
in classAbstractMemoryCache<K,
V> - Parameters:
hub
-
-
createMap
Description copied from class:AbstractMemoryCache
Children must implement this method. A FIFO implementation may use a tree map. An LRU might use a hashtable. The map returned should be threadsafe.- Specified by:
createMap
in classAbstractMemoryCache<K,
V> - Returns:
- a threadsafe Map
- See Also:
-
getKeySet
Description copied from class:AbstractMemoryCache
Get an Array of the keys for all elements in the memory cache- Specified by:
getKeySet
in interfaceIMemoryCache<K,
V> - Overrides:
getKeySet
in classAbstractMemoryCache<K,
V> - Returns:
- An Object[]
- See Also:
-
getSize
Returns the current cache size.- Specified by:
getSize
in interfaceIMemoryCache<K,
V> - Overrides:
getSize
in classAbstractMemoryCache<K,
V> - Returns:
- The size value
-
getStatistics
Description copied from interface:IMemoryCache
Returns the historical and statistical data for a region's memory cache.- Specified by:
getStatistics
in interfaceIMemoryCache<K,
V> - Overrides:
getStatistics
in classAbstractMemoryCache<K,
V> - Returns:
- statistics about the cache
-
lockedGetElement
Update control structures after get (guarded by the lock)- Specified by:
lockedGetElement
in classAbstractMemoryCache<K,
V> - Parameters:
me
- the memory element descriptor
-
lockedRemoveElement
Remove element from control structure (guarded by the lock)- Specified by:
lockedRemoveElement
in classAbstractMemoryCache<K,
V> - Parameters:
me
- the memory element descriptor
-
lockedRemoveAll
Removes all cached items from the cache control structures. (guarded by the lock)- Specified by:
lockedRemoveAll
in classAbstractMemoryCache<K,
V>
-
update
Puts an item to the cache.- Specified by:
update
in interfaceIMemoryCache<K,
V> - Specified by:
update
in classAbstractMemoryCache<K,
V> - Parameters:
ce
- Description of the Parameter- Throws:
IOException
- Description of the Exception
-
freeElements
This can't be implemented.- Parameters:
numberToFree
-- Returns:
- 0
- Throws:
IOException
-