Class CoherenceRegion
- java.lang.Object
-
- com.oracle.coherence.hibernate.cache.v53.region.CoherenceRegion
-
- All Implemented Interfaces:
org.hibernate.cache.spi.ExtendedStatisticsSupport
,org.hibernate.cache.spi.Region
public class CoherenceRegion extends Object implements org.hibernate.cache.spi.Region, org.hibernate.cache.spi.ExtendedStatisticsSupport
CoherenceRegion is an abstract superclass for classes representing different kinds of "region" in the Hibernate second-level cache. It abstracts behavior (and state) common to all types of Hibernate second-level cache region. Note that there is a concept (and therefore terminology) mapping between the Hibernate world and the Coherence world. Hibernate uses "cache" to mean the whole, and "region" to mean a part of the whole. Coherence uses "data grid" to mean the whole, and "NamedCache" to mean a part of the whole. So a "region" to Hibernate is a NamedCache to Coherence. Therefore, CoherenceRegion is basically an Adapter, adapting the Region SPI to the NamedCache API by encapsulating and delegating to a NamedCache.- Author:
- Randy Stafford, Gunnar Hillert
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_LOCK_LEASE_DURATION
The default lock lease duration in milliseconds.static String
LOCK_LEASE_DURATION_PROPERTY_NAME
The name of the property specifying the lock lease duration.
-
Constructor Summary
Constructors Constructor Description CoherenceRegion(org.hibernate.cache.spi.RegionFactory regionFactory, com.tangosol.net.NamedCache namedCache, Map<String,Object> properties)
Complete constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
contains(Object key)
void
destroy()
void
evict(Object key)
Evicts from this CoherenceRegion the entry at the argument key.void
evictAll()
Evicts all entries from this CoherenceRegion.protected long
getDurationProperty(Map<String,Object> properties, String propertyName, long defaultValue, long maxValue)
Get a duration value in milliseconds from the argument properties or defaults, capped at a maximum value.long
getElementCountInMemory()
long
getElementCountOnDisk()
String
getName()
protected com.tangosol.net.NamedCache
getNamedCache()
Returns the NamedCache implementing this CoherenceRegion.org.hibernate.cache.spi.RegionFactory
getRegionFactory()
long
getSizeInMemory()
int
getTimeout()
This method is undocumented in Hibernate javadoc.Object
getValue(Object key)
Returns the object at the argument key in this CoherenceRegion.Object
invoke(Object key, com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
Invoke the argument EntryProcessor on the argument key and return the result of the invocation.void
lockCache()
Locks the entire cache.long
newSoftLockExpirationTime()
Computes and returns the expiration time for a new soft lock.long
nextTimestamp()
This method is undocumented in Hibernate javadoc, but seems intended to return the "current" time.void
putValue(Object key, Object value)
Put the argument value into this CoherenceRegion at the argument key.String
toString()
}void
unlockCache()
Unlocks the entire cache.
-
-
-
Field Detail
-
LOCK_LEASE_DURATION_PROPERTY_NAME
public static final String LOCK_LEASE_DURATION_PROPERTY_NAME
The name of the property specifying the lock lease duration.- See Also:
- Constant Field Values
-
DEFAULT_LOCK_LEASE_DURATION
public static final int DEFAULT_LOCK_LEASE_DURATION
The default lock lease duration in milliseconds.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNamedCache
protected com.tangosol.net.NamedCache getNamedCache()
Returns the NamedCache implementing this CoherenceRegion.- Returns:
- the NamedCache implementing this CoherenceRegion
-
getRegionFactory
public org.hibernate.cache.spi.RegionFactory getRegionFactory()
- Specified by:
getRegionFactory
in interfaceorg.hibernate.cache.spi.Region
-
newSoftLockExpirationTime
public long newSoftLockExpirationTime()
Computes and returns the expiration time for a new soft lock.- Returns:
- a long representing the expiration time for a new soft lock
-
getValue
public Object getValue(Object key)
Returns the object at the argument key in this CoherenceRegion.- Parameters:
key
- the key of the sought object- Returns:
- the CoherenceRegionValue at the argument key in this CoherenceRegion
-
putValue
public void putValue(Object key, Object value)
Put the argument value into this CoherenceRegion at the argument key.- Parameters:
key
- the key at which to put the valuevalue
- the value to put
-
evict
public void evict(Object key)
Evicts from this CoherenceRegion the entry at the argument key.- Parameters:
key
- the key of the entry to remove
-
evictAll
public void evictAll()
Evicts all entries from this CoherenceRegion.
-
lockCache
public void lockCache()
Locks the entire cache.
-
unlockCache
public void unlockCache()
Unlocks the entire cache.
-
invoke
public Object invoke(Object key, com.tangosol.util.InvocableMap.EntryProcessor entryProcessor)
Invoke the argument EntryProcessor on the argument key and return the result of the invocation.- Parameters:
key
- the key on which to invoke the EntryProcessorentryProcessor
- the EntryProcessor to invoke.- Returns:
- the Object resulting from the EntryProcessor invocation
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.hibernate.cache.spi.Region
-
destroy
public void destroy() throws org.hibernate.cache.CacheException
- Specified by:
destroy
in interfaceorg.hibernate.cache.spi.Region
- Throws:
org.hibernate.cache.CacheException
-
contains
public boolean contains(Object key)
-
getSizeInMemory
public long getSizeInMemory()
- Specified by:
getSizeInMemory
in interfaceorg.hibernate.cache.spi.ExtendedStatisticsSupport
-
getElementCountInMemory
public long getElementCountInMemory()
- Specified by:
getElementCountInMemory
in interfaceorg.hibernate.cache.spi.ExtendedStatisticsSupport
-
getElementCountOnDisk
public long getElementCountOnDisk()
- Specified by:
getElementCountOnDisk
in interfaceorg.hibernate.cache.spi.ExtendedStatisticsSupport
-
nextTimestamp
public long nextTimestamp()
This method is undocumented in Hibernate javadoc, but seems intended to return the "current" time.- Returns:
- a millisecond clock value
-
getTimeout
public int getTimeout()
This method is undocumented in Hibernate javadoc. Comments in the Coherence-based implementation of the Hibernate 2.1 second-level cache SPI suggest the returned value is used as a lock lease duration.- Returns:
- an int lock lease duration
-
getDurationProperty
protected long getDurationProperty(Map<String,Object> properties, String propertyName, long defaultValue, long maxValue)
Get a duration value in milliseconds from the argument properties or defaults, capped at a maximum value.- Parameters:
properties
- the property set containing the propertypropertyName
- the name of the propertydefaultValue
- the default value (in milliseconds)maxValue
- the maximum value (saturating, in milliseconds)- Returns:
- a long duration value in milliseconds
-
clear
public void clear()
- Specified by:
clear
in interfaceorg.hibernate.cache.spi.Region
-
-