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

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


net.sf.hibernate.cache
Class EhCache

java.lang.Object
  extended bynet.sf.hibernate.cache.EhCache
All Implemented Interfaces:
Cache

public class EhCache
extends Object
implements Cache

EHCache plugin for Hibernate EHCache uses a MemoryStore and a DiskStore. The DiskStore requires that both keys and values be Serializable. For this reason this plugin throws Exceptions when either of these are not castable to Serializable.

Version:
Taken from EhCache 0.9
Author:
Greg Luck, Emmanuel Bernard

Constructor Summary
EhCache(net.sf.ehcache.Cache cache)
          Creates a new Hibernate pluggable cache based on a cache name.
 
Method Summary
 void clear()
          Remove all elements in the cache, but leave the cache in a useable state.
 void destroy()
          Remove the cache and make it unuseable.
 Object get(Object key)
          Gets a value of an element which matches the given key.
 int getTimeout()
          Returns the lock timeout for this cache.
 void lock(Object key)
          Calls to this method should perform there own synchronization.
 long nextTimestamp()
          Gets the next timestamp;
 void put(Object key, Object value)
          Puts an object into the cache.
 void remove(Object key)
          Removes the element which matches the key.
 void unlock(Object key)
          Calls to this method should perform there own synchronization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhCache

public EhCache(net.sf.ehcache.Cache cache)
Creates a new Hibernate pluggable cache based on a cache name.

Parameters:
cache - The underlying EhCache instance to use.
Method Detail

get

public Object get(Object key)
           throws CacheException
Gets a value of an element which matches the given key.

Specified by:
get in interface Cache
Parameters:
key - the key of the element to return.
Returns:
The value placed into the cache with an earlier put, or null if not found or expired
Throws:
CacheException

put

public void put(Object key,
                Object value)
         throws CacheException
Puts an object into the cache.

Specified by:
put in interface Cache
Parameters:
key - a Serializable key
value - a Serializable value
Throws:
CacheException - if the parameters are not Serializable, the CacheManager is shutdown or another Exception occurs.

remove

public void remove(Object key)
            throws CacheException
Removes the element which matches the key.

If no element matches, nothing is removed and no Exception is thrown.

Specified by:
remove in interface Cache
Parameters:
key - the key of the element to remove
Throws:
CacheException

clear

public void clear()
           throws CacheException
Remove all elements in the cache, but leave the cache in a useable state.

Specified by:
clear in interface Cache
Throws:
CacheException

destroy

public void destroy()
             throws CacheException
Remove the cache and make it unuseable.

Specified by:
destroy in interface Cache
Throws:
CacheException

lock

public void lock(Object key)
          throws CacheException
Calls to this method should perform there own synchronization. It is provided for distributed caches. Because EHCache is not distributed this method does nothing.

Specified by:
lock in interface Cache
Throws:
CacheException

unlock

public void unlock(Object key)
            throws CacheException
Calls to this method should perform there own synchronization. It is provided for distributed caches. Because EHCache is not distributed this method does nothing.

Specified by:
unlock in interface Cache
Throws:
CacheException

nextTimestamp

public long nextTimestamp()
Gets the next timestamp;

Specified by:
nextTimestamp in interface Cache

getTimeout

public int getTimeout()
Returns the lock timeout for this cache.

Specified by:
getTimeout in interface Cache