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

NonstrictReadWriteCache (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.cache
Class NonstrictReadWriteCache

java.lang.Object
  extended bynet.sf.hibernate.cache.NonstrictReadWriteCache
All Implemented Interfaces:
CacheConcurrencyStrategy

public class NonstrictReadWriteCache
extends Object
implements CacheConcurrencyStrategy

Caches data that is sometimes updated without ever locking the cache. If concurrent access to an item is possible, this concurrency strategy makes no guarantee that the item returned from the cache is the latest version available in the database. Configure your cache timeout accordingly! This is an "asynchronous" concurrency strategy.

Author:
Gavin King
See Also:
for a much stricter algorithm

Nested Class Summary
 
Nested classes inherited from class net.sf.hibernate.cache.CacheConcurrencyStrategy
CacheConcurrencyStrategy.SoftLock
 
Constructor Summary
NonstrictReadWriteCache()
           
 
Method Summary
 void afterInsert(Object key, Object value, Object version)
          Do nothing.
 void afterUpdate(Object key, Object value, Object version, CacheConcurrencyStrategy.SoftLock lock)
          Invalidate the item (again, for safety).
 void clear()
          Evict all items from the cache immediately.
 void destroy()
          Clean up all resources.
 void evict(Object key)
          Invalidate the item
 Object get(Object key, long txTimestamp)
          Get the most recent version, if available.
 void insert(Object key, Object value)
          Do nothing.
 CacheConcurrencyStrategy.SoftLock lock(Object key, Object version)
          Do nothing.
 boolean put(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator)
          Add an item to the cache.
 void release(Object key, CacheConcurrencyStrategy.SoftLock lock)
          Invalidate the item (again, for safety).
 void remove(Object key)
          Evict an item from the cache immediately (without regard for transaction isolation).
 void setCache(Cache cache)
          Set the underlying cache implementation.
 void setMinimalPuts(boolean minimalPuts)
          Enable "minimal puts" mode for this cache
 void update(Object key, Object value)
          Invalidate the item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonstrictReadWriteCache

public NonstrictReadWriteCache()
Method Detail

setCache

public void setCache(Cache cache)
Description copied from interface: CacheConcurrencyStrategy
Set the underlying cache implementation.

Specified by:
setCache in interface CacheConcurrencyStrategy
Parameters:
cache -

get

public Object get(Object key,
                  long txTimestamp)
           throws CacheException
Get the most recent version, if available.

Specified by:
get in interface CacheConcurrencyStrategy
Parameters:
key -
txTimestamp - a timestamp prior to the transaction start time
Returns:
the cached object or null
Throws:
CacheException

put

public boolean put(Object key,
                   Object value,
                   long txTimestamp,
                   Object version,
                   Comparator versionComparator)
            throws CacheException
Add an item to the cache.

Specified by:
put in interface CacheConcurrencyStrategy
Parameters:
key -
value -
txTimestamp - a timestamp prior to the transaction start time
version - the version number of the object we are putting
versionComparator - a Comparator to be used to compare version numbers
Returns:
true if the object was successfully cached
Throws:
CacheException

lock

public CacheConcurrencyStrategy.SoftLock lock(Object key,
                                              Object version)
                                       throws CacheException
Do nothing.

Specified by:
lock in interface CacheConcurrencyStrategy
Parameters:
key -
version -
Returns:
null, no lock
Throws:
CacheException

remove

public void remove(Object key)
            throws CacheException
Description copied from interface: CacheConcurrencyStrategy
Evict an item from the cache immediately (without regard for transaction isolation).

Specified by:
remove in interface CacheConcurrencyStrategy
Parameters:
key -
Throws:
CacheException

clear

public void clear()
           throws CacheException
Description copied from interface: CacheConcurrencyStrategy
Evict all items from the cache immediately.

Specified by:
clear in interface CacheConcurrencyStrategy
Throws:
CacheException

destroy

public void destroy()
Description copied from interface: CacheConcurrencyStrategy
Clean up all resources.

Specified by:
destroy in interface CacheConcurrencyStrategy

evict

public void evict(Object key)
           throws CacheException
Invalidate the item

Specified by:
evict in interface CacheConcurrencyStrategy
Throws:
CacheException

update

public void update(Object key,
                   Object value)
            throws CacheException
Invalidate the item

Specified by:
update in interface CacheConcurrencyStrategy
Throws:
CacheException

insert

public void insert(Object key,
                   Object value)
            throws CacheException
Do nothing.

Specified by:
insert in interface CacheConcurrencyStrategy
Throws:
CacheException

release

public void release(Object key,
                    CacheConcurrencyStrategy.SoftLock lock)
             throws CacheException
Invalidate the item (again, for safety).

Specified by:
release in interface CacheConcurrencyStrategy
Parameters:
key -
Throws:
CacheException

afterUpdate

public void afterUpdate(Object key,
                        Object value,
                        Object version,
                        CacheConcurrencyStrategy.SoftLock lock)
                 throws CacheException
Invalidate the item (again, for safety).

Specified by:
afterUpdate in interface CacheConcurrencyStrategy
Throws:
CacheException

afterInsert

public void afterInsert(Object key,
                        Object value,
                        Object version)
                 throws CacheException
Do nothing.

Specified by:
afterInsert in interface CacheConcurrencyStrategy
Throws:
CacheException

setMinimalPuts

public void setMinimalPuts(boolean minimalPuts)
                    throws HibernateException
Description copied from interface: CacheConcurrencyStrategy
Enable "minimal puts" mode for this cache

Specified by:
setMinimalPuts in interface CacheConcurrencyStrategy
Throws:
HibernateException