public class EhCache extends Object implements Cache
net.sf.ehcache.store.MemoryStore
and a
net.sf.ehcache.store.DiskStore
.
The net.sf.ehcache.store.DiskStore
requires that both keys and values be Serializable
.
However the MemoryStore does not and in ehcache-1.2 nonSerializable Objects are permitted. They are discarded
if an attempt it made to overflow them to Disk or to replicate them to remote cache peers.Constructor and Description |
---|
EhCache(net.sf.ehcache.Ehcache cache)
Creates a new Hibernate pluggable cache based on a cache name.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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()
Warning: This method can be very expensive to run.
|
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.
|
Object |
read(Object key)
Get an item from the cache
|
void |
remove(Object key)
Removes the element which matches the key.
|
Map |
toMap()
optional operation
|
String |
toString() |
void |
unlock(Object key)
Calls to this method should perform there own synchronization.
|
void |
update(Object key,
Object value)
Puts an object into the cache.
|
public EhCache(net.sf.ehcache.Ehcache cache)
cache
- The underlying EhCache instance to use.public Object get(Object key) throws CacheException
get
in interface Cache
key
- the key of the element to return.CacheException
public Object read(Object key) throws CacheException
Cache
read
in interface Cache
CacheException
public void update(Object key, Object value) throws CacheException
update
in interface Cache
key
- a keyvalue
- a valueCacheException
- if the CacheManager
is shutdown or another Exception
occurs.public void put(Object key, Object value) throws CacheException
put
in interface Cache
key
- a keyvalue
- a valueCacheException
- if the CacheManager
is shutdown or another Exception
occurs.public void remove(Object key) throws CacheException
remove
in interface Cache
key
- the key of the element to removeCacheException
public void clear() throws CacheException
clear
in interface Cache
CacheException
public void destroy() throws CacheException
destroy
in interface Cache
CacheException
public void lock(Object key) throws CacheException
lock
in interface Cache
CacheException
public void unlock(Object key) throws CacheException
unlock
in interface Cache
CacheException
public long nextTimestamp()
nextTimestamp
in interface Cache
public int getTimeout()
getTimeout
in interface Cache
public String getRegionName()
Cache
getRegionName
in interface Cache
public long getSizeInMemory()
getSizeInMemory
in interface Cache
public long getElementCountInMemory()
Cache
getElementCountInMemory
in interface Cache
public long getElementCountOnDisk()
Cache
getElementCountOnDisk
in interface Cache
Copyright © 2002-2015 Red Hat Middleware, LLC. All Rights Reserved