站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 3.2.3 正式版 API 英文文档

OptimisticTreeCache (Hibernate API Documentation) - Hibernate 3.2.3 正式版 API 英文文档


org.hibernate.cache
Class OptimisticTreeCache

java.lang.Object
  extended byorg.hibernate.cache.OptimisticTreeCache
All Implemented Interfaces:
Cache, OptimisticCache

public class OptimisticTreeCache
extends Object
implements OptimisticCache

Represents a particular region within the given JBossCache TreeCache utilizing TreeCache's optimistic locking capabilities.

Author:
Steve Ebersole
See Also:
for more details

Nested Class Summary
static class OptimisticTreeCache.CircumventChecksDataVersion
          Used to signal to a DataVersionAdapter to simply not perform any checks.
static class OptimisticTreeCache.DataVersionAdapter
           
static class OptimisticTreeCache.NonLockingDataVersion
          Used in regions where no locking should ever occur.
 
Constructor Summary
OptimisticTreeCache(org.jboss.cache.TreeCache cache, String regionName)
           
 
Method Summary
 void clear()
          Clear the cache
 void destroy()
          Clean up
 Object get(Object key)
          Get an item from the cache, nontransactionally
 long getElementCountInMemory()
          The count of entries currently contained in the regions in-memory store.
 long getElementCountOnDisk()
          The count of entries currently contained in the regions disk store.
 String getRegionName()
          Get the name of the cache region
 long getSizeInMemory()
          The number of bytes is this cache region currently consuming in memory.
 int getTimeout()
          Get a reasonable "lock timeout"
 void lock(Object key)
          If this is a clustered cache, lock the item
 long nextTimestamp()
          Generate a timestamp
 void put(Object key, Object value)
          Add an item to the cache, nontransactionally, with failfast semantics
 Object read(Object key)
          Get an item from the cache
 void remove(Object key)
          Remove an item from the cache
 void setSource(OptimisticCacheSource source)
          Indicates the "source" of the cached data.
 Map toMap()
          optional operation
 String toString()
           
 void unlock(Object key)
          If this is a clustered cache, unlock the item
 void update(Object key, Object value)
          Add an item to the cache
 void writeInsert(Object key, Object value, Object currentVersion)
          Called during CacheConcurrencyStrategy.insert(java.lang.Object, java.lang.Object, java.lang.Object) processing for transactional strategies.
 void writeLoad(Object key, Object value, Object currentVersion)
          Called during CacheConcurrencyStrategy.put(java.lang.Object, java.lang.Object, long, java.lang.Object, java.util.Comparator, boolean) processing for transactional strategies.
 void writeUpdate(Object key, Object value, Object currentVersion, Object previousVersion)
          Called during CacheConcurrencyStrategy.update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object) processing for transactional strategies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OptimisticTreeCache

public OptimisticTreeCache(org.jboss.cache.TreeCache cache,
                           String regionName)
                    throws CacheException
Method Detail

setSource

public void setSource(OptimisticCacheSource source)
Description copied from interface: OptimisticCache
Indicates the "source" of the cached data. Currently this will only ever represent an EntityPersister.

Made available to the cache so that it can access certain information about versioning strategy.

Specified by:
setSource in interface OptimisticCache
Parameters:
source - The source.

writeInsert

public void writeInsert(Object key,
                        Object value,
                        Object currentVersion)
Description copied from interface: OptimisticCache
Called during CacheConcurrencyStrategy.insert(java.lang.Object, java.lang.Object, java.lang.Object) processing for transactional strategies. Indicates we have just performed an insert into the DB and now need to cache that entity's data.

Specified by:
writeInsert in interface OptimisticCache
Parameters:
key - The cache key.
value - The data to be cached.
currentVersion - The entity's version; or null if not versioned.

writeUpdate

public void writeUpdate(Object key,
                        Object value,
                        Object currentVersion,
                        Object previousVersion)
Description copied from interface: OptimisticCache
Called during CacheConcurrencyStrategy.update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object) processing for transactional strategies. Indicates we have just performed an update against the DB and now need to cache the updated state.

Specified by:
writeUpdate in interface OptimisticCache
Parameters:
key - The cache key.
value - The data to be cached.
currentVersion - The entity's current version
previousVersion - The entity's previous version (before the update); or null if not versioned.

writeLoad

public void writeLoad(Object key,
                      Object value,
                      Object currentVersion)
Description copied from interface: OptimisticCache
Called during CacheConcurrencyStrategy.put(java.lang.Object, java.lang.Object, long, java.lang.Object, java.util.Comparator, boolean) processing for transactional strategies. Indicates we have just loaded an entity's state from the database and need it cached.

Specified by:
writeLoad in interface OptimisticCache
Parameters:
key - The cache key.
value - The data to be cached.
currentVersion - The entity's version; or null if not versioned.

get

public Object get(Object key)
           throws CacheException
Description copied from interface: Cache
Get an item from the cache, nontransactionally

Specified by:
get in interface Cache
Parameters:
key -
Returns:
the cached object or null
Throws:
CacheException

read

public Object read(Object key)
            throws CacheException
Description copied from interface: Cache
Get an item from the cache

Specified by:
read in interface Cache
Parameters:
key -
Returns:
the cached object or null
Throws:
CacheException

update

public void update(Object key,
                   Object value)
            throws CacheException
Description copied from interface: Cache
Add an item to the cache

Specified by:
update in interface Cache
Parameters:
key -
value -
Throws:
CacheException

put

public void put(Object key,
                Object value)
         throws CacheException
Description copied from interface: Cache
Add an item to the cache, nontransactionally, with failfast semantics

Specified by:
put in interface Cache
Parameters:
key -
value -
Throws:
CacheException

remove

public void remove(Object key)
            throws CacheException
Description copied from interface: Cache
Remove an item from the cache

Specified by:
remove in interface Cache
Throws:
CacheException

clear

public void clear()
           throws CacheException
Description copied from interface: Cache
Clear the cache

Specified by:
clear in interface Cache
Throws:
CacheException

destroy

public void destroy()
             throws CacheException
Description copied from interface: Cache
Clean up

Specified by:
destroy in interface Cache
Throws:
CacheException

lock

public void lock(Object key)
          throws CacheException
Description copied from interface: Cache
If this is a clustered cache, lock the item

Specified by:
lock in interface Cache
Throws:
CacheException

unlock

public void unlock(Object key)
            throws CacheException
Description copied from interface: Cache
If this is a clustered cache, unlock the item

Specified by:
unlock in interface Cache
Throws:
CacheException

nextTimestamp

public long nextTimestamp()
Description copied from interface: Cache
Generate a timestamp

Specified by:
nextTimestamp in interface Cache

getTimeout

public int getTimeout()
Description copied from interface: Cache
Get a reasonable "lock timeout"

Specified by:
getTimeout in interface Cache

getRegionName

public String getRegionName()
Description copied from interface: Cache
Get the name of the cache region

Specified by:
getRegionName in interface Cache

getSizeInMemory

public long getSizeInMemory()
Description copied from interface: Cache
The number of bytes is this cache region currently consuming in memory.

Specified by:
getSizeInMemory in interface Cache
Returns:
The number of bytes consumed by this region; -1 if unknown or unsupported.

getElementCountInMemory

public long getElementCountInMemory()
Description copied from interface: Cache
The count of entries currently contained in the regions in-memory store.

Specified by:
getElementCountInMemory in interface Cache
Returns:
The count of entries in memory; -1 if unknown or unsupported.

getElementCountOnDisk

public long getElementCountOnDisk()
Description copied from interface: Cache
The count of entries currently contained in the regions disk store.

Specified by:
getElementCountOnDisk in interface Cache
Returns:
The count of entries on disk; -1 if unknown or unsupported.

toMap

public Map toMap()
Description copied from interface: Cache
optional operation

Specified by:
toMap in interface Cache

toString

public String toString()