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 protected
VersionConsistencyCacheImpl(boolean highPerf)
Creates a cache with desired performance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPCType(Class pcType)
This implementation does nothing.StateManager
get(Class pcType, Object oid)
Returns an SM, if found, else null.boolean
isHighPerf()
StateManager
put(Class pcType, Object oid, StateManager sm)
Puts the given StateManager into a map that is keyed by the given OID.StateManager
remove(Class pcType, Object oid)
Removes entry based on pc and oid.void
removePCType(Class pcType)
Removes the map for the given pcType and all its elements.int
size()
-
-
-
Method Detail
-
put
public StateManager put(Class pcType, Object oid, StateManager sm)
Description copied from interface:VersionConsistencyCache
Puts 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:
put
in interfaceVersionConsistencyCache
- Parameters:
pcType
- class of instance, used as key in outer map.oid
- Object id, used as key in inner map.sm
- StateManager bound tooid
in 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:VersionConsistencyCache
Returns an SM, if found, else null.- Specified by:
get
in 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:VersionConsistencyCache
Removes entry based on pc and oid. If map is empty after remove, removes it from its containint map.- Specified by:
remove
in 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:
addPCType
in interfaceVersionConsistencyCache
- Parameters:
pcType
- class of instance, used as key in outer map.
-
removePCType
public void removePCType(Class pcType)
Description copied from interface:VersionConsistencyCache
Removes the map for the given pcType and all its elements.- Specified by:
removePCType
in 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.
-
-