public class SoftCacheWeakIdentityMap extends HardCacheWeakIdentityMap
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.
Responsibilities:
HardCacheWeakIdentityMap.ReferenceCacheKey
referenceCache
cleanupCount, cleanupSize
cacheKeys
maxSize, searchKey
Constructor and Description |
---|
SoftCacheWeakIdentityMap(int size) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
buildReference(java.lang.Object object)
Creates a Soft reference if Required
|
boolean |
hasReference(java.lang.Object reference)
Checks if the object is null, or reference's object is null.
|
createCacheKey, getReferenceCache, put, remove, updateMaxSize
cleanupDeadCacheKeys, getCleanupCount, getCleanupSize, setCleanupCount, setCleanupSize
clone, collectLocks, elements, getCacheKey, getCacheKeys, getSize, getSize, keys, put, resetCacheKey, resetCacheKey, setCacheKeys
acquireDeferredLock, acquireLock, acquireLockNoWait, acquireReadLockOnCacheKey, acquireReadLockOnCacheKeyNoWait, containsKey, createCacheKey, get, getCacheKey, getCacheKeyWithReadLock, getDefaultIdentityMapClass, getMaxSize, getSearchKey, getWrapper, getWriteLockValue, initialize, remove, setMaxSize, setSearchKey, setWrapper, setWriteLockValue, toString, updateCacheKey
public java.lang.Object buildReference(java.lang.Object object)
buildReference
in class HardCacheWeakIdentityMap
object
- is the domain object to cache.public boolean hasReference(java.lang.Object reference)
hasReference
in class HardCacheWeakIdentityMap
the
- object for hard or the reference for soft.