ehcache

net.sf.ehcache.hibernate
Class EhCache

java.lang.Object
  extended by net.sf.ehcache.hibernate.EhCache
All Implemented Interfaces:
org.hibernate.cache.Cache

Deprecated.

@Deprecated
public final class EhCache
extends Object
implements org.hibernate.cache.Cache

EHCache plugin for Hibernate.

EHCache uses a MemoryStore and a DiskStore.

The 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.

Version:
$Id: EhCache.java 5631 2012-05-10 08:31:33Z teck $
Author:
Greg Luck, Emmanuel Bernard

Constructor Summary
EhCache(Ehcache cache)
          Deprecated. Creates a new Hibernate pluggable cache by name.
 
Method Summary
 boolean canLockEntries()
          Deprecated.  
 void clear()
          Deprecated. Remove all elements in the cache, but leave the cache in a useable state.
 void destroy()
          Deprecated. Remove the cache and make it unuseable.
 Object get(Object key)
          Deprecated. Gets a value of an element which matches the given key.
 long getElementCountInMemory()
          Deprecated.  
 long getElementCountOnDisk()
          Deprecated.  
 String getRegionName()
          Deprecated.  
 long getSizeInMemory()
          Deprecated. Warning: This method can be very expensive to run.
 int getTimeout()
          Deprecated. Returns the lock timeout for this cache, which is 60s
 void lock(Object key)
          Deprecated. 
 long nextTimestamp()
          Deprecated. Gets the next timestamp;
 void put(Object key, Object value)
          Deprecated. Puts an object into the cache.
 Object read(Object key)
          Deprecated. Gets an object from the cache.
 void remove(Object key)
          Deprecated. Removes the element which matches the key.
 Map toMap()
          Deprecated.  
 String toString()
          Deprecated.  
 void unlock(Object key)
          Deprecated. 
 void update(Object key, Object value)
          Deprecated. Updates an object in the cache, or if it does not exist, inserts it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 Object get(Object key)
                 throws org.hibernate.cache.CacheException
Deprecated. 
Gets a value of an element which matches the given key.

Specified by:
get in interface org.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 Object read(Object key)
                  throws org.hibernate.cache.CacheException
Deprecated. 
Gets an object from the cache.

Specified by:
read in interface org.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(Object key,
                         Object value)
                  throws org.hibernate.cache.CacheException
Deprecated. 
Updates an object in the cache, or if it does not exist, inserts it.

Specified by:
update in interface org.hibernate.cache.Cache
Parameters:
key - an Object key
value - an Object value
Throws:
org.hibernate.cache.CacheException - if the CacheManager is shutdown or another Exception occurs.

put

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

Specified by:
put in interface org.hibernate.cache.Cache
Parameters:
key - an Object key
value - an Object value
Throws:
org.hibernate.cache.CacheException - if the CacheManager is shutdown or another Exception occurs.

remove

public final void remove(Object key)
                  throws org.hibernate.cache.CacheException
Deprecated. 
Removes the element which matches the key.

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

Specified by:
remove in interface org.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.CacheException
Deprecated. 
Remove all elements in the cache, but leave the cache in a useable state.

Specified by:
clear in interface org.hibernate.cache.Cache
Throws:
org.hibernate.cache.CacheException

destroy

public final void destroy()
                   throws org.hibernate.cache.CacheException
Deprecated. 
Remove the cache and make it unuseable.

Specified by:
destroy in interface org.hibernate.cache.Cache
Throws:
org.hibernate.cache.CacheException

lock

public final void lock(Object key)
                throws org.hibernate.cache.CacheException
Deprecated. 

Specified by:
lock in interface org.hibernate.cache.Cache
Throws:
org.hibernate.cache.CacheException

unlock

public final void unlock(Object key)
                  throws org.hibernate.cache.CacheException
Deprecated. 

Specified by:
unlock in interface org.hibernate.cache.Cache
Throws:
org.hibernate.cache.CacheException

nextTimestamp

public final long nextTimestamp()
Deprecated. 
Gets the next timestamp;

Specified by:
nextTimestamp in interface org.hibernate.cache.Cache

getTimeout

public final int getTimeout()
Deprecated. 
Returns the lock timeout for this cache, which is 60s

Specified by:
getTimeout in interface org.hibernate.cache.Cache

getRegionName

public final String getRegionName()
Deprecated. 
Specified by:
getRegionName in interface org.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:
getSizeInMemory in interface org.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:
getElementCountInMemory in interface org.hibernate.cache.Cache
Returns:
the number of elements in ehcache's MemoryStore

getElementCountOnDisk

public final long getElementCountOnDisk()
Deprecated. 
Specified by:
getElementCountOnDisk in interface org.hibernate.cache.Cache
Returns:
the number of elements in ehcache's DiskStore. 0 is there is no DiskStore

toMap

public final Map toMap()
Deprecated. 
Specified by:
toMap in interface org.hibernate.cache.Cache
Returns:
a copy of the cache Elements as a Map

canLockEntries

public final boolean canLockEntries()
Deprecated. 
Returns:
true if this cache supports entry locks.

toString

public final String toString()
Deprecated. 
Overrides:
toString in class Object
Returns:
the region name, which is the cache name in ehcache

ehcache

Copyright © 2003-2014 Terracotta, Inc.. All Rights Reserved.