FileDocCategorySizeDatePackage
SoftCacheWeakIdentityMap.javaAPI DocGlassfish v2 API3389Tue May 22 16:54:36 BST 2007oracle.toplink.essentials.internal.identitymaps

SoftCacheWeakIdentityMap

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:

  • Guarantees identity
  • Allows garbage collection
  • Increases performance through maintaining a fixed size cache of MRU objects when memory is available
  • The default size of the reference cache is half the max size
since
TOPLink/Java 1.2

Fields Summary
Constructors Summary
public SoftCacheWeakIdentityMap(int size)

        super(size);
    
Methods Summary
public java.lang.ObjectbuildReference(java.lang.Object object)
Creates a Soft reference if Required

param
object is the domain object to cache.

        return new SoftReference(object);
    
public booleanhasReference(java.lang.Object reference)
Checks if the object is null, or reference's object is null.

param
the object for hard or the reference for soft.

        return (reference != null) && (((SoftReference)reference).get() != null);