public class HardCacheWeakIdentityMap extends WeakIdentityMap
Purpose: A weak cache is identical to the weak identity map, however the weak can be a performance problem for some types of apps because it can cause too much garbage collection of objects read causing them to be re-read and re-built (this defeats the purpose of the cache). The weak cache solves this through also holding a fixed number of objects is memory to improve caching. This makes used of an exposed node linked list to maintain the objects by storing the link nodes in the cache key.
Responsibilities:
| Modifier and Type | Class and Description |
|---|---|
class |
HardCacheWeakIdentityMap.ReferenceCacheKey
Inner class to define the specialized weak cache key.
|
| Modifier and Type | Field and Description |
|---|---|
protected ExposedNodeLinkedList |
referenceCache |
cleanupCount, cleanupSizecacheKeysmaxSize, searchKey| Constructor and Description |
|---|
HardCacheWeakIdentityMap(int size) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
buildReference(java.lang.Object object)
Creates a Soft reference if Required
|
CacheKey |
createCacheKey(java.util.Vector primaryKey,
java.lang.Object object,
java.lang.Object writeLockValue,
long readTime)
Use a ReferenceCacheKey that also stores the linked list node to manage
the LRU sub-cache of references.
|
ExposedNodeLinkedList |
getReferenceCache()
Return the linked reference cache.
|
boolean |
hasReference(java.lang.Object reference)
Checks if the object is null, or reference's object is null.
|
protected void |
put(CacheKey cacheKey)
Store the object in the cache with the cache key.
|
java.lang.Object |
remove(CacheKey cacheKey)
Remove the cache key from the map and the sub-cache list.
|
void |
updateMaxSize(int maxSize)
This method will be used to update the max cache size.
|
cleanupDeadCacheKeys, getCleanupCount, getCleanupSize, setCleanupCount, setCleanupSizeclone, collectLocks, elements, getCacheKey, getCacheKeys, getSize, getSize, keys, put, resetCacheKey, resetCacheKey, setCacheKeysacquireDeferredLock, acquireLock, acquireLockNoWait, acquireReadLockOnCacheKey, acquireReadLockOnCacheKeyNoWait, containsKey, createCacheKey, get, getCacheKey, getCacheKeyWithReadLock, getDefaultIdentityMapClass, getMaxSize, getSearchKey, getWrapper, getWriteLockValue, initialize, remove, setMaxSize, setSearchKey, setWrapper, setWriteLockValue, toString, updateCacheKeyprotected ExposedNodeLinkedList referenceCache
public CacheKey createCacheKey(java.util.Vector primaryKey, java.lang.Object object, java.lang.Object writeLockValue, long readTime)
createCacheKey in class WeakIdentityMappublic ExposedNodeLinkedList getReferenceCache()
public java.lang.Object buildReference(java.lang.Object object)
object - is the domain object to cache.public boolean hasReference(java.lang.Object reference)
the - object for hard or the reference for soft.protected void put(CacheKey cacheKey)
put in class WeakIdentityMappublic java.lang.Object remove(CacheKey cacheKey)
remove in class FullIdentityMappublic void updateMaxSize(int maxSize)
updateMaxSize in class IdentityMap