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
referenceCache
Fields inherited from class org.eclipse.persistence.internal.identitymaps.WeakIdentityMap
cleanupCount, cleanupSize
Fields inherited from class org.eclipse.persistence.internal.identitymaps.FullIdentityMap
cacheKeys
Fields inherited from class org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap
descriptor, isIsolated, maxSize, session
-
Constructor Summary
ConstructorDescriptionSoftCacheWeakIdentityMap
(int size, ClassDescriptor descriptor, AbstractSession session, boolean isIsolated) -
Method Summary
Modifier and TypeMethodDescriptionbuildReference
(Object object) Creates a Soft reference to the object.boolean
hasReference
(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, updateMaxSize
Methods inherited from class org.eclipse.persistence.internal.identitymaps.WeakIdentityMap
checkCleanup, cleanupDeadCacheKeys, putCacheKeyIfAbsent
Methods inherited from class org.eclipse.persistence.internal.identitymaps.FullIdentityMap
clone, cloneKeys, collectLocks, elements, getCacheKey, getCacheKeys, getSize, getSize, keys, keys, lazyRelationshipLoaded, resetCacheKey, setCacheKeys
Methods 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:
buildReference
in classHardCacheWeakIdentityMap
- Parameters:
object
- is the domain object to cache.
-
hasReference
Checks if the object is null, or reference's object is null.- Overrides:
hasReference
in classHardCacheWeakIdentityMap
- Parameters:
reference
- the object for hard or the reference for soft.
-