Package org.datanucleus.cache
Class JavaxCacheLevel2Cache
java.lang.Object
org.datanucleus.cache.AbstractLevel2Cache
org.datanucleus.cache.JavaxCacheLevel2Cache
- All Implemented Interfaces:
Serializable
,Level2Cache
Simple implementation of a plugin for use of javax.cache (v0.61+) product with DataNucleus.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javax.cache.Cache
Cache of CachedPC keyed by "id".private javax.cache.Cache
Cache of "id" keyed by "uniqueKey".static final String
private static final long
Fields inherited from class org.datanucleus.cache.AbstractLevel2Cache
cacheName, clearAtClose, expiryMillis, maxSize, nucleusCtx
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Method to close the cache when no longer needed.boolean
containsOid
(Object oid) Accessor for whether the cache contains the specified id.void
Evict the parameter instance from the second-level cache.void
evictAll()
Evict the parameter instances from the second-level cache.void
Evict the parameter instances from the second-level cache.void
Evict the parameter instances from the second-level cache.void
evictAll
(Collection oids) Evict the parameter instances from the second-level cache.(package private) void
evictAllOfClass
(String className) Accessor for an object in the cache.getAll
(Collection oids) Accessor for a collection of objects from the cache.getUnique
(CacheUniqueKey key) Method to retrieve the id represented by the specified unique key.Method to add an object to the cache under its idvoid
Method to put several objects into the cache.putUnique
(CacheUniqueKey key, CachedPC pc) Method to store a persistable object for this unique key.void
putUniqueAll
(Map<CacheUniqueKey, CachedPC> objs) Method to put several objects into the cache.void
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 Details
-
NAME
- See Also:
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
cache
private javax.cache.Cache cacheCache of CachedPC keyed by "id". -
cacheUnique
private javax.cache.Cache cacheUniqueCache of "id" keyed by "uniqueKey".
-
-
Constructor Details
-
JavaxCacheLevel2Cache
Constructor.- Parameters:
nucleusCtx
- Context
-
-
Method Details
-
close
public void close()Method to close the cache when no longer needed. Provides a hook to release resources etc. -
containsOid
Accessor for whether the cache contains the specified id.- Parameters:
oid
- The object id- Returns:
- Whether it is in the cache
- See Also:
-
get
Accessor for an object in the cache.- Parameters:
oid
- The Object ID- Returns:
- The L2 cacheable object
- See Also:
-
getAll
Description copied from interface:Level2Cache
Accessor 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
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
Description copied from interface:Level2Cache
Method to put several objects into the cache.- Parameters:
objs
- Map of cacheable object keyed by its oid.
-
evict
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
Evict the parameter instances from the second-level cache.- Parameters:
oids
- the object ids of the instance to evict.
-
evictAll
Evict the parameter instances from the second-level cache.- Parameters:
oids
- the object ids of the instance to evict.
-
evictAll
Evict the parameter instances from the second-level cache.- Parameters:
pcClass
- the class of instances to evictsubclasses
- if true, evict instances of subclasses also
-
evictAllOfClass
-
getUnique
Description copied from interface:Level2Cache
Method 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
Description copied from interface:Level2Cache
Method 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
Description copied from interface:Level2Cache
Method to put several objects into the cache.- Parameters:
objs
- Map of cacheable object keyed by the unique keys.
-
removeUnique
Description copied from interface:Level2Cache
Method to remove any object cached against the provided unique key.- Parameters:
key
- Unique key
-