Class VersionConsistencyCacheImpl
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.sqlstore.impl.VersionConsistencyCacheImpl
-
- All Implemented Interfaces:
VersionConsistencyCache
public class VersionConsistencyCacheImpl extends Object implements VersionConsistencyCache
A 2-level cache of StateManager instances (i.e., a map of maps). The inner map is a BucketizedHashtable or a LRU cache, depending on parameter given at construction.- Author:
- Dave Bristor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedVersionConsistencyCacheImpl(boolean highPerf)Creates a cache with desired performance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPCType(Class pcType)This implementation does nothing.StateManagerget(Class pcType, Object oid)Returns an SM, if found, else null.booleanisHighPerf()StateManagerput(Class pcType, Object oid, StateManager sm)Puts the given StateManager into a map that is keyed by the given OID.StateManagerremove(Class pcType, Object oid)Removes entry based on pc and oid.voidremovePCType(Class pcType)Removes the map for the given pcType and all its elements.intsize()
-
-
-
Method Detail
-
put
public StateManager put(Class pcType, Object oid, StateManager sm)
Description copied from interface:VersionConsistencyCachePuts the given StateManager into a map that is keyed by the given OID. We anticipate that implementations will want to use a two-level map, and so the pc's class can be used as a key into a map to access a second map, which would be that keyed by OID.- Specified by:
putin interfaceVersionConsistencyCache- Parameters:
pcType- class of instance, used as key in outer map.oid- Object id, used as key in inner map.sm- StateManager bound tooidin inner map.- See Also:
VersionConsistencyCache.put(java.lang.Class, java.lang.Object, com.sun.jdo.spi.persistence.support.sqlstore.StateManager)
-
get
public StateManager get(Class pcType, Object oid)
Description copied from interface:VersionConsistencyCacheReturns an SM, if found, else null.- Specified by:
getin interfaceVersionConsistencyCache- Parameters:
pcType- class of instance, used as key in outer map.oid- Object id, used as key in inner map.- See Also:
VersionConsistencyCache.get(java.lang.Class, java.lang.Object)
-
remove
public StateManager remove(Class pcType, Object oid)
Description copied from interface:VersionConsistencyCacheRemoves entry based on pc and oid. If map is empty after remove, removes it from its containint map.- Specified by:
removein interfaceVersionConsistencyCache- Parameters:
pcType- class of instance, used as key in outer map.oid- Object id, used as key in inner map.- See Also:
VersionConsistencyCache.remove(java.lang.Class, java.lang.Object)
-
addPCType
public void addPCType(Class pcType)
This implementation does nothing. Instead, we create buckets for each pcType as-needed; seeput(java.lang.Class, java.lang.Object, com.sun.jdo.spi.persistence.support.sqlstore.StateManager)- Specified by:
addPCTypein interfaceVersionConsistencyCache- Parameters:
pcType- class of instance, used as key in outer map.
-
removePCType
public void removePCType(Class pcType)
Description copied from interface:VersionConsistencyCacheRemoves the map for the given pcType and all its elements.- Specified by:
removePCTypein interfaceVersionConsistencyCache- Parameters:
pcType- class of instance, used as key in outer map.- See Also:
VersionConsistencyCache.removePCType(java.lang.Class)
-
size
public int size()
- Returns:
- the number of elements in the cache.
-
isHighPerf
public boolean isHighPerf()
- Returns:
- true if this cache is based on LRU cache; false otherwise.
-
-