Module org.eclipse.persistence.core
Class SoftCacheWeakIdentityMap
java.lang.Object
org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
org.eclipse.persistence.internal.identitymaps.FullIdentityMap
org.eclipse.persistence.internal.identitymaps.WeakIdentityMap
org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap
org.eclipse.persistence.internal.identitymaps.SoftCacheWeakIdentityMap
- All Implemented Interfaces:
Serializable,Cloneable,IdentityMap
Purpose: A SoftCacheWeakIdentityMap is identical to the WeakIdentityMap, however the weak reference 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 SoftCacheWeakIdentityMap solves this through also holding a fixed number of objects in memory to improve caching.
Responsibilities:
- Guarantees identity
- Allows garbage collection
- Increases performance by maintaining a fixed size cache of MRU objects when memory is available.
- The default size of the reference cache is the max size.
- Since:
- TOPLink/Java 1.2
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap
HardCacheWeakIdentityMap.ReferenceCacheKey -
Field Summary
Fields inherited from class org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap
referenceCacheFields inherited from class org.eclipse.persistence.internal.identitymaps.WeakIdentityMap
cleanupCount, cleanupSizeFields inherited from class org.eclipse.persistence.internal.identitymaps.FullIdentityMap
cacheKeysFields inherited from class org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
descriptor, isIsolated, maxSize, session -
Constructor Summary
ConstructorsConstructorDescriptionSoftCacheWeakIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isIsolated) -
Method Summary
Modifier and TypeMethodDescriptionbuildReference(Object object) Creates a Soft reference to the object.booleanhasReference(Object reference) Checks if the object is null, or reference's object is null.Methods inherited from class org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap
createCacheKey, getReferenceCache, put, remove, updateMaxSizeMethods inherited from class org.eclipse.persistence.internal.identitymaps.WeakIdentityMap
checkCleanup, cleanupDeadCacheKeys, putCacheKeyIfAbsentMethods inherited from class org.eclipse.persistence.internal.identitymaps.FullIdentityMap
clone, cloneKeys, collectLocks, elements, getCacheKey, getCacheKeys, getSize, getSize, keys, keys, lazyRelationshipLoaded, resetCacheKey, setCacheKeysMethods inherited from class org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
acquireDeferredLock, acquireLock, acquireLockNoWait, acquireLockWithWait, acquireReadLockOnCacheKey, acquireReadLockOnCacheKeyNoWait, containsKey, get, getAllCacheKeysFromIdentityMapWithEntityPK, getAllFromIdentityMapWithEntityPK, getCacheKeyForLock, getCacheKeyWithReadLock, getDefaultIdentityMapClass, getDescriptor, getDescriptorClass, getMaxSize, getWrapper, getWriteLockValue, release, remove, setDescriptor, setMaxSize, setWrapper, setWriteLockValue, toString
-
Constructor Details
-
SoftCacheWeakIdentityMap
public SoftCacheWeakIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isIsolated)
-
-
Method Details
-
buildReference
Creates a Soft reference to the object.- Overrides:
buildReferencein classHardCacheWeakIdentityMap- Parameters:
object- is the domain object to cache.
-
hasReference
Checks if the object is null, or reference's object is null.- Overrides:
hasReferencein classHardCacheWeakIdentityMap- Parameters:
reference- the object for hard or the reference for soft.
-