Class EhCache

  • All Implemented Interfaces:
    org.hibernate.cache.Cache

    @Deprecated
    public final class EhCache
    extends java.lang.Object
    implements org.hibernate.cache.Cache
    Deprecated.
    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$
    Author:
    Greg Luck, Emmanuel Bernard
    • Constructor Summary

      Constructors 
      Constructor Description
      EhCache​(Ehcache cache)
      Deprecated.
      Creates a new Hibernate pluggable cache by name.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      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.
      java.lang.Object get​(java.lang.Object key)
      Deprecated.
      Gets a value of an element which matches the given key.
      long getElementCountInMemory()
      Deprecated.
       
      long getElementCountOnDisk()
      Deprecated.
       
      java.lang.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​(java.lang.Object key)
      Deprecated.
      long nextTimestamp()
      Deprecated.
      Gets the next timestamp;
      void put​(java.lang.Object key, java.lang.Object value)
      Deprecated.
      Puts an object into the cache.
      java.lang.Object read​(java.lang.Object key)
      Deprecated.
      Gets an object from the cache.
      void remove​(java.lang.Object key)
      Deprecated.
      Removes the element which matches the key.
      java.util.Map toMap()
      Deprecated.
       
      java.lang.String toString()
      Deprecated.
       
      void unlock​(java.lang.Object key)
      Deprecated.
      void update​(java.lang.Object key, java.lang.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 java.lang.Object get​(java.lang.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 java.lang.Object read​(java.lang.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​(java.lang.Object key,
                                 java.lang.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​(java.lang.Object key,
                              java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.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 java.util.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 java.lang.String toString()
        Deprecated.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the region name, which is the cache name in ehcache