org.springframework.cache.ehcache

## Class EhCacheCache

- java.lang.Object
- - org.springframework.cache.ehcache.EhCacheCache

- All Implemented Interfaces:
    Cache

      public class EhCacheCache
      extends Object
      implements Cache

  `Cache` implementation on top of an `Ehcache` instance.
  Since:
    3.1
  Author:
    Costin Leau, Juergen Hoeller

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.springframework.cache.Cache

      `Cache.ValueWrapper`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EhCacheCache(net.sf.ehcache.Ehcache ehcache)` Create an `EhCacheCache` instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Remove all mappings from the cache.
    `void` | `evict(Object key)` Evict the mapping for this key from this cache if it is present.
    `Cache.ValueWrapper` | `get(Object key)` Return the value to which this cache maps the specified key.
    `String` | `getName()` Return the cache name.
    `net.sf.ehcache.Ehcache` | `getNativeCache()` Return the the underlying native cache provider.
    `void` | `put(Object key, Object value)` Associate the specified value with the specified key in this cache.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EhCacheCache

          public EhCacheCache(net.sf.ehcache.Ehcache ehcache)

      Create an `EhCacheCache` instance.
      Parameters:
        `ehcache` - backing Ehcache instance

  - ### Method Detail

    - #### getName

          public String getName()

      Description copied from interface: `Cache`
      Return the cache name.
      Specified by:
        `getName` in interface `Cache`

    - #### getNativeCache

          public net.sf.ehcache.Ehcache getNativeCache()

      Description copied from interface: `Cache`
      Return the the underlying native cache provider.
      Specified by:
        `getNativeCache` in interface `Cache`

    - #### get

          public Cache.ValueWrapper get(Object key)

      Description copied from interface: `Cache`
      Return the value to which this cache maps the specified key. Returns `null` if the cache contains no mapping for this key.
      Specified by:
        `get` in interface `Cache`
      Parameters:
        `key` - key whose associated value is to be returned.
      Returns:
        the value to which this cache maps the specified key, or `null` if the cache contains no mapping for this key

    - #### put

          public void put(Object key,
                 Object value)

      Description copied from interface: `Cache`
      Associate the specified value with the specified key in this cache.

      If the cache previously contained a mapping for this key, the old value is replaced by the specified value.

      Specified by:
        `put` in interface `Cache`
      Parameters:
        `key` - the key with which the specified value is to be associated
        `value` - the value to be associated with the specified key

    - #### evict

          public void evict(Object key)

      Description copied from interface: `Cache`
      Evict the mapping for this key from this cache if it is present.
      Specified by:
        `evict` in interface `Cache`
      Parameters:
        `key` - the key whose mapping is to be removed from the cache

    - #### clear

          public void clear()

      Description copied from interface: `Cache`
      Remove all mappings from the cache.
      Specified by:
        `clear` in interface `Cache`