Package net.sf.ehcache.hibernate
Class EhCache
- java.lang.Object
-
- net.sf.ehcache.hibernate.EhCache
-
- All Implemented Interfaces:
org.hibernate.cache.Cache
@Deprecated public final class EhCache extends java.lang.Object implements org.hibernate.cache.CacheDeprecated.EHCache plugin for Hibernate.EHCache uses a
MemoryStoreand aDiskStore.The
DiskStorerequires that both keys and values beSerializable. 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.- Version:
- $Id$
- Author:
- Greg Luck, Emmanuel Bernard
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanLockEntries()Deprecated.voidclear()Deprecated.Remove all elements in the cache, but leave the cache in a useable state.voiddestroy()Deprecated.Remove the cache and make it unuseable.java.lang.Objectget(java.lang.Object key)Deprecated.Gets a value of an element which matches the given key.longgetElementCountInMemory()Deprecated.longgetElementCountOnDisk()Deprecated.java.lang.StringgetRegionName()Deprecated.longgetSizeInMemory()Deprecated.Warning: This method can be very expensive to run.intgetTimeout()Deprecated.Returns the lock timeout for this cache, which is 60svoidlock(java.lang.Object key)Deprecated.longnextTimestamp()Deprecated.Gets the next timestamp;voidput(java.lang.Object key, java.lang.Object value)Deprecated.Puts an object into the cache.java.lang.Objectread(java.lang.Object key)Deprecated.Gets an object from the cache.voidremove(java.lang.Object key)Deprecated.Removes the element which matches the key.java.util.MaptoMap()Deprecated.java.lang.StringtoString()Deprecated.voidunlock(java.lang.Object key)Deprecated.voidupdate(java.lang.Object key, java.lang.Object value)Deprecated.Updates an object in the cache, or if it does not exist, inserts it.
-
-
-
Constructor Detail
-
EhCache
public EhCache(Ehcache cache)
Deprecated.Creates a new Hibernate pluggable cache by name.ehcache will look in ehcache.xml to load the configuration for the cache. If the cache is not there, it will use the defaultCache settings. It is always a good idea to specifically configure each cache.
- Parameters:
cache- The backing ehcache cache.
-
-
Method Detail
-
get
public final java.lang.Object get(java.lang.Object key) throws org.hibernate.cache.CacheExceptionDeprecated.Gets a value of an element which matches the given key.- Specified by:
getin interfaceorg.hibernate.cache.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:
org.hibernate.cache.CacheException
-
read
public final java.lang.Object read(java.lang.Object key) throws org.hibernate.cache.CacheExceptionDeprecated.Gets an object from the cache.- Specified by:
readin interfaceorg.hibernate.cache.Cache- Parameters:
key- an Object value- Returns:
- the Object, or null if not found
- Throws:
org.hibernate.cache.CacheException
-
update
public final void update(java.lang.Object key, java.lang.Object value) throws org.hibernate.cache.CacheExceptionDeprecated.Updates an object in the cache, or if it does not exist, inserts it.- Specified by:
updatein interfaceorg.hibernate.cache.Cache- Parameters:
key- an Object keyvalue- an Object value- Throws:
org.hibernate.cache.CacheException- if theCacheManageris shutdown or anotherExceptionoccurs.
-
put
public final void put(java.lang.Object key, java.lang.Object value) throws org.hibernate.cache.CacheExceptionDeprecated.Puts an object into the cache.- Specified by:
putin interfaceorg.hibernate.cache.Cache- Parameters:
key- an Object keyvalue- an Object value- Throws:
org.hibernate.cache.CacheException- if theCacheManageris shutdown or anotherExceptionoccurs.
-
remove
public final void remove(java.lang.Object key) throws org.hibernate.cache.CacheExceptionDeprecated.Removes the element which matches the key.If no element matches, nothing is removed and no Exception is thrown.
- Specified by:
removein interfaceorg.hibernate.cache.Cache- Parameters:
key- the key of the element to remove- Throws:
org.hibernate.cache.CacheException
-
clear
public final void clear() throws org.hibernate.cache.CacheExceptionDeprecated.Remove all elements in the cache, but leave the cache in a useable state.- Specified by:
clearin interfaceorg.hibernate.cache.Cache- Throws:
org.hibernate.cache.CacheException
-
destroy
public final void destroy() throws org.hibernate.cache.CacheExceptionDeprecated.Remove the cache and make it unuseable.- Specified by:
destroyin interfaceorg.hibernate.cache.Cache- Throws:
org.hibernate.cache.CacheException
-
lock
public final void lock(java.lang.Object key) throws org.hibernate.cache.CacheExceptionDeprecated.- Specified by:
lockin interfaceorg.hibernate.cache.Cache- Throws:
org.hibernate.cache.CacheException
-
unlock
public final void unlock(java.lang.Object key) throws org.hibernate.cache.CacheExceptionDeprecated.- Specified by:
unlockin interfaceorg.hibernate.cache.Cache- Throws:
org.hibernate.cache.CacheException
-
nextTimestamp
public final long nextTimestamp()
Deprecated.Gets the next timestamp;- Specified by:
nextTimestampin interfaceorg.hibernate.cache.Cache
-
getTimeout
public final int getTimeout()
Deprecated.Returns the lock timeout for this cache, which is 60s- Specified by:
getTimeoutin interfaceorg.hibernate.cache.Cache
-
getRegionName
public final java.lang.String getRegionName()
Deprecated.- Specified by:
getRegionNamein interfaceorg.hibernate.cache.Cache- Returns:
- the region name of the cache, which is the cache name in ehcache
-
getSizeInMemory
public final long getSizeInMemory()
Deprecated.Warning: This method can be very expensive to run. Allow approximately 1 second per 1MB of entries. Running this method could create liveness problems because the object lock is held for a long period- Specified by:
getSizeInMemoryin interfaceorg.hibernate.cache.Cache- Returns:
- the approximate size of memory ehcache is using for the MemoryStore for this cache
-
getElementCountInMemory
public final long getElementCountInMemory()
Deprecated.- Specified by:
getElementCountInMemoryin interfaceorg.hibernate.cache.Cache- Returns:
- the number of elements in ehcache's MemoryStore
-
getElementCountOnDisk
public final long getElementCountOnDisk()
Deprecated.- Specified by:
getElementCountOnDiskin interfaceorg.hibernate.cache.Cache- Returns:
- the number of elements in ehcache's DiskStore. 0 is there is no DiskStore
-
toMap
public final java.util.Map toMap()
Deprecated.- Specified by:
toMapin interfaceorg.hibernate.cache.Cache- Returns:
- a copy of the cache Elements as a Map
-
canLockEntries
public final boolean canLockEntries()
Deprecated.- Returns:
trueif this cache supports entry locks.
-
toString
public final java.lang.String toString()
Deprecated.- Overrides:
toStringin classjava.lang.Object- Returns:
- the region name, which is the cache name in ehcache
-
-