- java.lang.Object
-
- org.datanucleus.cache.AbstractLevel2Cache
-
- org.datanucleus.cache.JavaxCacheLevel2Cache
-
- All Implemented Interfaces:
Serializable,Level2Cache
public class JavaxCacheLevel2Cache extends AbstractLevel2Cache
Simple implementation of a plugin for use of javax.cache (v0.61+) product with DataNucleus.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringNAME-
Fields inherited from class org.datanucleus.cache.AbstractLevel2Cache
cacheName, clearAtClose, expiryMillis, maxSize, nucleusCtx
-
-
Constructor Summary
Constructors Constructor Description JavaxCacheLevel2Cache(NucleusContext nucleusCtx)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Method to close the cache when no longer needed.booleancontainsOid(Object oid)Accessor for whether the cache contains the specified id.voidevict(Object oid)Evict the parameter instance from the second-level cache.voidevictAll()Evict the parameter instances from the second-level cache.voidevictAll(Class pcClass, boolean subclasses)Evict the parameter instances from the second-level cache.voidevictAll(Object[] oids)Evict the parameter instances from the second-level cache.voidevictAll(Collection oids)Evict the parameter instances from the second-level cache.CachedPCget(Object oid)Accessor for an object in the cache.Map<Object,CachedPC>getAll(Collection oids)Accessor for a collection of objects from the cache.CachedPCgetUnique(CacheUniqueKey key)Method to retrieve the id represented by the specified unique key.CachedPCput(Object oid, CachedPC pc)Method to add an object to the cache under its idvoidputAll(Map<Object,CachedPC> objs)Method to put several objects into the cache.CachedPCputUnique(CacheUniqueKey key, CachedPC pc)Method to store a persistable object for this unique key.voidputUniqueAll(Map<CacheUniqueKey,CachedPC> objs)Method to put several objects into the cache.voidremoveUnique(CacheUniqueKey key)Method to remove any object cached against the provided unique key.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.datanucleus.cache.Level2Cache
getNumberOfPinnedObjects, getNumberOfUnpinnedObjects, getSize, isEmpty, pin, pinAll, pinAll, pinAll, unpin, unpinAll, unpinAll, unpinAll
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JavaxCacheLevel2Cache
public JavaxCacheLevel2Cache(NucleusContext nucleusCtx)
Constructor.- Parameters:
nucleusCtx- Context
-
-
Method Detail
-
close
public void close()
Method to close the cache when no longer needed. Provides a hook to release resources etc.
-
containsOid
public boolean containsOid(Object oid)
Accessor for whether the cache contains the specified id.- Parameters:
oid- The object id- Returns:
- Whether it is in the cache
- See Also:
Level2Cache.containsOid(java.lang.Object)
-
get
public CachedPC get(Object oid)
Accessor for an object in the cache.- Parameters:
oid- The Object ID- Returns:
- The L2 cacheable object
- See Also:
Level2Cache.get(java.lang.Object)
-
getAll
public Map<Object,CachedPC> getAll(Collection oids)
Description copied from interface:Level2CacheAccessor for a collection of objects from the cache.- Parameters:
oids- The Object IDs- Returns:
- Map of the objects, keyed by the oids that are found
-
put
public CachedPC put(Object oid, CachedPC pc)
Method to add an object to the cache under its id- Parameters:
oid- The identitypc- The cacheable object- Returns:
- The value previously associated with this oid
-
putAll
public void putAll(Map<Object,CachedPC> objs)
Description copied from interface:Level2CacheMethod to put several objects into the cache.- Parameters:
objs- Map of cacheable object keyed by its oid.
-
evict
public void evict(Object oid)
Evict the parameter instance from the second-level cache.- Parameters:
oid- the object id of the instance to evict.
-
evictAll
public void evictAll()
Evict the parameter instances from the second-level cache. All instances in the PersistenceManager's cache are evicted from the second-level cache.
-
evictAll
public void evictAll(Collection oids)
Evict the parameter instances from the second-level cache.- Parameters:
oids- the object ids of the instance to evict.
-
evictAll
public void evictAll(Object[] oids)
Evict the parameter instances from the second-level cache.- Parameters:
oids- the object ids of the instance to evict.
-
evictAll
public void evictAll(Class pcClass, boolean subclasses)
Evict the parameter instances from the second-level cache.- Parameters:
pcClass- the class of instances to evictsubclasses- if true, evict instances of subclasses also
-
getUnique
public CachedPC getUnique(CacheUniqueKey key)
Description copied from interface:Level2CacheMethod to retrieve the id represented by the specified unique key.- Parameters:
key- Unique key- Returns:
- The "identity" of the object that this unique key represents
-
putUnique
public CachedPC putUnique(CacheUniqueKey key, CachedPC pc)
Description copied from interface:Level2CacheMethod to store a persistable object for this unique key.- Parameters:
key- The unique keypc- The representation of the persistable object to cache- Returns:
- The previous object for this unique key if one was present, otherwise null
-
putUniqueAll
public void putUniqueAll(Map<CacheUniqueKey,CachedPC> objs)
Description copied from interface:Level2CacheMethod to put several objects into the cache.- Parameters:
objs- Map of cacheable object keyed by the unique keys.
-
removeUnique
public void removeUnique(CacheUniqueKey key)
Description copied from interface:Level2CacheMethod to remove any object cached against the provided unique key.- Parameters:
key- Unique key
-
-