Class CoherenceRegion
java.lang.Object
com.oracle.coherence.hibernate.cache.v6.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
Modifier and TypeFieldDescriptionstatic final int
The default lock lease duration in milliseconds.static final String
The name of the property specifying the lock lease duration. -
Constructor Summary
ConstructorDescriptionCoherenceRegion
(org.hibernate.cache.spi.RegionFactory regionFactory, com.tangosol.net.NamedCache namedCache, Map<String, Object> properties) Complete constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
void
destroy()
void
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
long
getName()
protected com.tangosol.net.NamedCache
Returns the NamedCache implementing this CoherenceRegion.org.hibernate.cache.spi.RegionFactory
long
int
This method is undocumented in Hibernate javadoc.Returns the object at the argument key in this CoherenceRegion.Invoke the argument EntryProcessor on the argument key and return the result of the invocation.void
Locks the entire cache.long
Computes and returns the expiration time for a new soft lock.long
This method is undocumented in Hibernate javadoc, but seems intended to return the "current" time.void
Put the argument value into this CoherenceRegion at the argument key.toString()
}void
Unlocks the entire cache.
-
Field Details
-
LOCK_LEASE_DURATION_PROPERTY_NAME
The name of the property specifying the lock lease duration.- See Also:
-
DEFAULT_LOCK_LEASE_DURATION
public static final int DEFAULT_LOCK_LEASE_DURATIONThe default lock lease duration in milliseconds.- See Also:
-
-
Constructor Details
-
Method Details
-
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
-
toString
} -
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
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
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
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
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
- 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
-
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
-