Class CoherenceLevel2Cache

  • All Implemented Interfaces:
    Serializable, org.datanucleus.cache.Level2Cache

    public class CoherenceLevel2Cache
    extends org.datanucleus.cache.AbstractLevel2Cache
    Simple implementation of a plugin for use of Oracles Coherence distributed caching product with DataNucleus. Please refer to www.tangosol.com for full details of their products. This plugin simply provides a wrapper to the Coherence "NamedCache" to allow its use in DataNucleus.
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class org.datanucleus.cache.AbstractLevel2Cache

        cacheName, clearAtClose, expiryMillis, maxSize, nucleusCtx
    • Constructor Summary

      Constructors 
      Constructor Description
      CoherenceLevel2Cache​(org.datanucleus.NucleusContext nucleusCtx)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void 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​(Object oid)
      Evict the parameter instance from the second-level cache.
      void evictAll()
      Evict the parameter instances from the second-level cache.
      void evictAll​(Class pcClass, boolean subclasses)
      Evict the parameter instances from the second-level cache.
      void evictAll​(Object[] oids)
      Evict the parameter instances from the second-level cache.
      void evictAll​(Collection oids)
      Evict the parameter instances from the second-level cache.
      org.datanucleus.cache.CachedPC get​(Object oid)
      Accessor for an object in the cache.
      com.tangosol.net.NamedCache getCoherenceCache()
      Accessor for the backing Coherence cache.
      int getSize()
      Accessor for the size of the cache.
      boolean isEmpty()
      Accessor for whether the cache is empty
      boolean lock​(Object oid)
      Method to lock the underlying Coherence cache.
      boolean lock​(Object oid, int wait)
      Method to lock the underlying Coherence cache for a time period.
      org.datanucleus.cache.CachedPC put​(Object oid, org.datanucleus.cache.CachedPC pc)
      Method to add an object to the cache under its id
      boolean unlock​(Object oid)
      Method to unlock the underlying Coherence cache.
      • Methods inherited from interface org.datanucleus.cache.Level2Cache

        getAll, getNumberOfPinnedObjects, getNumberOfUnpinnedObjects, getUnique, pin, pinAll, pinAll, pinAll, putAll, putUnique, putUniqueAll, removeUnique, unpin, unpinAll, unpinAll, unpinAll
    • Constructor Detail

      • CoherenceLevel2Cache

        public CoherenceLevel2Cache​(org.datanucleus.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.
      • getCoherenceCache

        public com.tangosol.net.NamedCache getCoherenceCache()
        Accessor for the backing Coherence cache. This is provided so that users can add much more elaborate control over their cache in line with what Coherence provides.
        Returns:
        The Coherence named cache.
      • containsOid

        public boolean containsOid​(Object oid)
        Accessor for whether the cache contains the specified id.
        See Also:
        Level2Cache.containsOid(java.lang.Object)
      • lock

        public boolean lock​(Object oid)
        Method to lock the underlying Coherence cache.
        Parameters:
        oid - The key
        Returns:
        Success indicator
      • lock

        public boolean lock​(Object oid,
                            int wait)
        Method to lock the underlying Coherence cache for a time period.
        Parameters:
        oid - The key
        wait - the time period (ms)
        Returns:
        Success indicator
      • unlock

        public boolean unlock​(Object oid)
        Method to unlock the underlying Coherence cache.
        Parameters:
        oid - The key
        Returns:
        Success indicator
      • get

        public org.datanucleus.cache.CachedPC get​(Object oid)
        Accessor for an object in the cache.
        See Also:
        Level2Cache.get(java.lang.Object)
      • getSize

        public int getSize()
        Accessor for the size of the cache.
        See Also:
        Level2Cache.getSize()
      • isEmpty

        public boolean isEmpty()
        Accessor for whether the cache is empty
        See Also:
        Level2Cache.isEmpty()
      • put

        public org.datanucleus.cache.CachedPC put​(Object oid,
                                                  org.datanucleus.cache.CachedPC pc)
        Method to add an object to the cache under its id
        Parameters:
        oid - The identity
        pc - The cacheable object
        Returns:
        previous value for this identity (if any)
      • 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​(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
      • 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.