org.datanucleus.cache.ehcache
Class EhcacheClassBasedLevel2Cache

java.lang.Object
  extended by org.datanucleus.cache.AbstractLevel2Cache
      extended by org.datanucleus.cache.ehcache.EhcacheClassBasedLevel2Cache
All Implemented Interfaces:
Serializable, org.datanucleus.cache.Level2Cache

public class EhcacheClassBasedLevel2Cache
extends org.datanucleus.cache.AbstractLevel2Cache

Plugin for EHCache that allows the user to use different caches for different classes. Based on the EhcacheLevel2Cache class.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.datanucleus.cache.Level2Cache
org.datanucleus.cache.Level2Cache.PinnedClass
 
Field Summary
 
Fields inherited from class org.datanucleus.cache.AbstractLevel2Cache
cacheName, clearAtClose, LOCALISER, maxSize, nucleusCtx, timeout
 
Constructor Summary
EhcacheClassBasedLevel2Cache(org.datanucleus.NucleusContext nucleusCtx)
          Constructor.
 
Method Summary
 void close()
          Method to close the cache when no longer needed.
 boolean containsOid(Object oid)
          Accessor for whether an object with the specified id is in the cache
 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(Collection oids)
          Evict the parameter instances from the second-level cache.
 void evictAll(Object[] oids)
          Evict the parameter instances from the second-level cache.
 org.datanucleus.cache.CachedPC get(Object oid)
          Accessor for an object from the cache.
 int getSize()
          Accessor for the size of the cache.
 org.datanucleus.cache.CachedPC put(Object oid, org.datanucleus.cache.CachedPC pc)
          Method to add an object to the cache under its id
 
Methods inherited from class org.datanucleus.cache.AbstractLevel2Cache
getAll, getNumberOfPinnedObjects, getNumberOfUnpinnedObjects, isEmpty, pin, pinAll, pinAll, pinAll, putAll, unpin, unpinAll, unpinAll, unpinAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhcacheClassBasedLevel2Cache

public EhcacheClassBasedLevel2Cache(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.


containsOid

public boolean containsOid(Object oid)
Accessor for whether an object with the specified id is in the cache

Parameters:
oid - The object id
Returns:
Whether it is in the cache

get

public org.datanucleus.cache.CachedPC get(Object oid)
Accessor for an object from the cache.

Parameters:
oid - The Object ID
Returns:
The L2 cacheable object

getSize

public int getSize()
Accessor for the size of the cache.

See Also:
Level2Cache.getSize()

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

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.


Copyright © 2011. All Rights Reserved.