Class JavaxCacheLevel2Cache

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:
  • Field Details

    • NAME

      public static final String NAME
      See Also:
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • cache

      private javax.cache.Cache cache
      Cache of CachedPC keyed by "id".
    • cacheUnique

      private javax.cache.Cache cacheUnique
      Cache of "id" keyed by "uniqueKey".
  • Constructor Details

    • JavaxCacheLevel2Cache

      public JavaxCacheLevel2Cache(NucleusContext nucleusCtx)
      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

      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:
    • 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:
    • getAll

      public Map<Object,CachedPC> getAll(Collection oids)
      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

      public CachedPC put(Object oid, CachedPC pc)
      Method to add an object to the cache under its id
      Parameters:
      oid - The identity
      pc - The cacheable object
      Returns:
      The value previously associated with this oid
    • putAll

      public void putAll(Map<Object,CachedPC> objs)
      Description copied from interface: Level2Cache
      Method 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 evict
      subclasses - if true, evict instances of subclasses also
    • evictAllOfClass

      void evictAllOfClass(String className)
    • getUnique

      public CachedPC getUnique(CacheUniqueKey key)
      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

      public CachedPC putUnique(CacheUniqueKey key, CachedPC pc)
      Description copied from interface: Level2Cache
      Method to store a persistable object for this unique key.
      Parameters:
      key - The unique key
      pc - 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: Level2Cache
      Method 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: Level2Cache
      Method to remove any object cached against the provided unique key.
      Parameters:
      key - Unique key