Oracle® Coherence Java API Reference
v3.5.3

E15583-01

com.tangosol.coherence.hibernate
Class CoherenceCache

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.coherence.hibernate.CoherenceCache

public class CoherenceCache
extends Base

Provides a cache wrapper for storing Hibernate objects in Coherence NamedCache instances.

Author:
jp 2005.08.31, jh 2005.08.31

Field Summary
protected static int DEFAULT_LOCK_LEASE_MILLIS
          The default lock lease millis
protected static int DEFAULT_LOCK_OBTAIN_MILLIS
          The default lock attempt millis
static java.lang.String LOCK_LEASE_TIMEOUT
          The system property specifying the lock lease timeout
static java.lang.String LOCK_OBTAIN_TIMEOUT
          The system property specifying the lock acquisition timeout
 
Constructor Summary
CoherenceCache(NamedCache cache, java.util.Properties properties)
          Construct a Hibernate cache instance.
 
Method Summary
 void clear()
          Clear the entire cache.
 void destroy()
          Release local (JVM) resources associated with this cache.
 java.lang.Object get(java.lang.Object oKey)
          Get an object from the cache.
 long getElementCountInMemory()
          Get the size of the cache in memory (object count)
 long getElementCountOnDisk()
          Get the size of the cache on disk (object count)
protected  int getLockLeaseTimeout()
          Get the timeout (in millis) for lock leases.
protected  int getLockObtainTimeout()
          Get the timeout (in millis) for lock acquisition attempts.
 java.lang.String getRegionName()
          Get the region (cache) name.
 long getSizeInMemory()
          Get the size of the cache in memory (byte count)
 int getTimeout()
          Get the lock timeout (lease duration, not lock acquisition).
protected  long getTimeProperty(java.util.Properties properties, java.lang.String sPropertyName, long cDefaultMillis, long cMaxMillis)
          Get an adjusted time (duration) property
 void lock(java.lang.Object oKey)
          Lock a key.
 long nextTimestamp()
          Get the current timestamp (in millis).
 void put(java.lang.Object oKey, java.lang.Object oValue)
          Put an object into the cache.
 java.lang.Object read(java.lang.Object oKey)
          Get an object from the cache.
 void remove(java.lang.Object oKey)
          Remove an object from the cache.
 java.util.Map toMap()
          Get a Map instance representing the contents of the cache.
 void unlock(java.lang.Object oKey)
          Unlock a key.
 void update(java.lang.Object oKey, java.lang.Object oValue)
          Update an item in the cache.
 

Field Detail

LOCK_OBTAIN_TIMEOUT

public static final java.lang.String LOCK_OBTAIN_TIMEOUT
The system property specifying the lock acquisition timeout

See Also:
Constant Field Values

DEFAULT_LOCK_OBTAIN_MILLIS

protected static final int DEFAULT_LOCK_OBTAIN_MILLIS
The default lock attempt millis

See Also:
Constant Field Values

LOCK_LEASE_TIMEOUT

public static final java.lang.String LOCK_LEASE_TIMEOUT
The system property specifying the lock lease timeout

See Also:
Constant Field Values

DEFAULT_LOCK_LEASE_MILLIS

protected static final int DEFAULT_LOCK_LEASE_MILLIS
The default lock lease millis

See Also:
Constant Field Values
Constructor Detail

CoherenceCache

public CoherenceCache(NamedCache cache,
                      java.util.Properties properties)
Construct a Hibernate cache instance.

Parameters:
cache - the Coherence NamedCache instance that provides the actual data storage
properties - the configuration properties
Method Detail

get

public java.lang.Object get(java.lang.Object oKey)
Get an object from the cache.

Parameters:
oKey - the cache key
Returns:
the cache value

read

public java.lang.Object read(java.lang.Object oKey)
Get an object from the cache.

Parameters:
oKey - the cache key
Returns:
the cache value

put

public void put(java.lang.Object oKey,
                java.lang.Object oValue)
Put an object into the cache.

Parameters:
oKey - the cache key
oValue - the cache value

remove

public void remove(java.lang.Object oKey)
Remove an object from the cache.

Parameters:
oKey - the cache key

clear

public void clear()
Clear the entire cache.


destroy

public void destroy()
Release local (JVM) resources associated with this cache.


getTimeout

public int getTimeout()
Get the lock timeout (lease duration, not lock acquisition).

Returns:
the lock timeout in millis

nextTimestamp

public long nextTimestamp()
Get the current timestamp (in millis).

Returns:
the current timestamp

lock

public void lock(java.lang.Object oKey)
Lock a key.

Parameters:
oKey - the cache key
Throws:
CacheException - if lock acquisition times out

unlock

public void unlock(java.lang.Object oKey)
Unlock a key.

Parameters:
oKey - the cache key

update

public void update(java.lang.Object oKey,
                   java.lang.Object oValue)
Update an item in the cache.

Parameters:
oKey - the cache key
oValue - the cache value

getRegionName

public java.lang.String getRegionName()
Get the region (cache) name.

Returns:
the region (cache) name.

getSizeInMemory

public long getSizeInMemory()
Get the size of the cache in memory (byte count)

Not supported (returns -1).

Note: Used only by the Cache Statistics package

Returns:
the number of bytes used by the cache

getElementCountInMemory

public long getElementCountInMemory()
Get the size of the cache in memory (object count)

Not supported (returns total cache size, including disk).

Note: Used only by the Cache Statistics package

Returns:
the number of objects in the cache that are in RAM

getElementCountOnDisk

public long getElementCountOnDisk()
Get the size of the cache on disk (object count)

Not supported (returns -1).

Note: Used only by the Cache Statistics package

Returns:
the number of objects in the cache that are on disk

toMap

public java.util.Map toMap()
Get a Map instance representing the contents of the cache.

This implementation simply returns the Coherence NamedCache instance.

Returns:
the Map representation of the cache

getLockObtainTimeout

protected int getLockObtainTimeout()
Get the timeout (in millis) for lock acquisition attempts.

Returns:
the timeout (in millis)

getLockLeaseTimeout

protected int getLockLeaseTimeout()
Get the timeout (in millis) for lock leases.

Returns:
the timeout (in millis)

getTimeProperty

protected long getTimeProperty(java.util.Properties properties,
                               java.lang.String sPropertyName,
                               long cDefaultMillis,
                               long cMaxMillis)
Get an adjusted time (duration) property

Parameters:
properties - the property set containing the property
sPropertyName - the name of the property
cDefaultMillis - the default value (in milliseconds)
cMaxMillis - the maximum value (saturating, in milliseconds)
Returns:
the time value

Oracle® Coherence Java API Reference
v3.5.3

E15583-01

Copyright © 2000, 2010, Oracle. All rights reserved.