Top Description Fields Constructors Methods
org.eclipse.persistence.internal.identitymaps

public Class CacheIdentityMap

extends FullIdentityMap
Class Inheritance
Imports
org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.internal.sessions.AbstractSession

Purpose: A fixed size LRU cache

Using a linked list as well as the map from the superclass a LRU cache is maintained. When a get is executed the LRU list is updated and when a new object is inserted the object at the start of the list is deleted (provided the maxSize has been reached).

Responsibilities:

Since
TOPLink/Java 1.0

Field Summary

Modifier and TypeField and Description
protected LinkedCacheKey
first

Provide handles on the linked list

protected LinkedCacheKey
last

Provide handles on the linked list

Inherited from org.eclipse.persistence.internal.identitymaps.FullIdentityMap:
cacheKeys

Constructor Summary

AccessConstructor and Description
public
CacheIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)

Method Summary

Modifier and TypeMethod and Description
public CacheKey
createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime)

Overrides org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.createCacheKey.

Create the correct type of CacheKey for this map.
protected void
ensureFixedSize()

Reduces the size of the receiver down to the maxSize removing objects from the start of the linked list.

public CacheKey

Returns:

the LinkedCacheKey or null if none found for primaryKey
getCacheKey
(Object
is the primary key for the object to search for.
primaryKeys
,
boolean forMerge)

Overrides org.eclipse.persistence.internal.identitymaps.FullIdentityMap.getCacheKey.

Implements org.eclipse.persistence.internal.identitymaps.IdentityMap.getCacheKey.

Access the object within the table for the given primaryKey.
protected CacheKey
public Object

Returns:

the LinkedCacheKey to be removed.
remove
(CacheKey key)

Overrides org.eclipse.persistence.internal.identitymaps.FullIdentityMap.remove.

Implements org.eclipse.persistence.internal.identitymaps.IdentityMap.remove.

Remove the LinkedCacheKey from the cache as well as from the linked list.
public synchronized void
updateMaxSize(int maxSize)

Overrides org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.updateMaxSize.

Implements org.eclipse.persistence.internal.identitymaps.IdentityMap.updateMaxSize.

INTERNAL: This method will be used to update the max cache size, any objects exceeding the max cache size will be remove from the cache.
Inherited from org.eclipse.persistence.internal.identitymaps.FullIdentityMap:
clonecloneKeyscollectLockselementsgetCacheKeysgetSizegetSizekeyskeyslazyRelationshipLoadedputresetCacheKeysetCacheKeys

Field Detail

firstback to summary
protected LinkedCacheKey first

Provide handles on the linked list

lastback to summary
protected LinkedCacheKey last

Provide handles on the linked list

Constructor Detail

CacheIdentityMapback to summary
public CacheIdentityMap(int size, ClassDescriptor descriptor, AbstractSession session, boolean isolated)

Method Detail

createCacheKeyback to summary
public CacheKey createCacheKey(Object primaryKey, Object object, Object writeLockValue, long readTime)

Overrides org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.createCacheKey.

Doc from org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.createCacheKey.

Create the correct type of CacheKey for this map.

Annotations
@Override
ensureFixedSizeback to summary
protected void ensureFixedSize()

Reduces the size of the receiver down to the maxSize removing objects from the start of the linked list.

getCacheKeyback to summary
public CacheKey getCacheKey(Object primaryKeys, boolean forMerge)

Overrides org.eclipse.persistence.internal.identitymaps.FullIdentityMap.getCacheKey.

Implements org.eclipse.persistence.internal.identitymaps.IdentityMap.getCacheKey.

Access the object within the table for the given primaryKey. Move the accessed key to the top of the order keys linked list to maintain LRU.

Parameters
primaryKeys:Object

is the primary key for the object to search for.

Returns:CacheKey

the LinkedCacheKey or null if none found for primaryKey

Annotations
@Override
putCacheKeyIfAbsentback to summary
protected CacheKey putCacheKeyIfAbsent(CacheKey searchKey)

Overrides org.eclipse.persistence.internal.identitymaps.FullIdentityMap.putCacheKeyIfAbsent.

Also insert the link if the cacheKey is put.

Annotations
@Override
removeback to summary
public Object remove(CacheKey key)

Overrides org.eclipse.persistence.internal.identitymaps.FullIdentityMap.remove.

Implements org.eclipse.persistence.internal.identitymaps.IdentityMap.remove.

Remove the LinkedCacheKey from the cache as well as from the linked list.

Returns:Object

the LinkedCacheKey to be removed.

Annotations
@Override
updateMaxSizeback to summary
public synchronized void updateMaxSize(int maxSize)

Overrides org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.updateMaxSize.

Implements org.eclipse.persistence.internal.identitymaps.IdentityMap.updateMaxSize.

INTERNAL: This method will be used to update the max cache size, any objects exceeding the max cache size will be remove from the cache. Please note that this does not remove the object from the identityMap, except in the case of the CacheIdentityMap.

Annotations
@Override