Class EhCacheAdapter

java.lang.Object
org.axonframework.common.caching.AbstractCacheAdapter<org.ehcache.event.CacheEventListener>
org.axonframework.common.caching.EhCacheAdapter
All Implemented Interfaces:
Cache

public class EhCacheAdapter extends AbstractCacheAdapter<org.ehcache.event.CacheEventListener>
Cache implementation that delegates all calls to an EhCache instance.
Since:
2.1.2
Author:
Allard Buijze, Gerard Klijs
  • Constructor Details

    • EhCacheAdapter

      public EhCacheAdapter(org.ehcache.core.Ehcache ehCache)
      Initialize the adapter to forward all call to the given ehCache instance
      Parameters:
      ehCache - The cache instance to forward calls to
  • Method Details

    • get

      public <K, V> V get(K key)
      Description copied from interface: Cache
      Returns an item from the cache, or null if no item was stored under that key
      Type Parameters:
      K - The type of key used
      V - The type of value stored
      Parameters:
      key - The key under which the item was cached
      Returns:
      the item stored under the given key
    • put

      public void put(Object key, Object value)
      Description copied from interface: Cache
      Stores the given value in the cache, under given key. If an item already exists, it is updated with the new value.
      Parameters:
      key - The key under which to store the item
      value - The item to cache
    • putIfAbsent

      public boolean putIfAbsent(Object key, Object value)
      Description copied from interface: Cache
      Stores the given value in the cache, under given key, if no element is yet available under that key. This operation is performed atomically.
      Parameters:
      key - The key under which to store the item
      value - The item to cache
      Returns:
      true if no value was previously assigned to the key, false otherwise.
    • remove

      public boolean remove(Object key)
      Description copied from interface: Cache
      Removes the entry stored under given key. If no such entry exists, nothing happens.
      Parameters:
      key - The key under which the item was stored
      Returns:
      true if a value was previously assigned to the key and has been removed, false otherwise.
    • removeAll

      public void removeAll()
      Description copied from interface: Cache
      Remove all stored entries in this cache.
    • containsKey

      public boolean containsKey(Object key)
      Description copied from interface: Cache
      Indicates whether there is an item stored under given key.
      Parameters:
      key - The key to check
      Returns:
      true if an item is available under that key, false otherwise.
    • computeIfPresent

      public <V> void computeIfPresent(Object key, UnaryOperator<V> update)
      Description copied from interface: Cache
      Perform the update in the value behind the given key. The update is only executed if there's an entry referencing the key.
      Type Parameters:
      V - The type of the value to execute the update for.
      Parameters:
      key - The key to perform an update for, if not empty.
      update - The update to perform if the key is present.
    • createListenerAdapter

      protected org.ehcache.event.CacheEventListener createListenerAdapter(Cache.EntryListener cacheEntryListener)
      Description copied from class: AbstractCacheAdapter
      Creates an adapter for the given cacheEntryListener. The adapter must forward all incoming notifications to the respective methods on the cacheEntryListener.
      Specified by:
      createListenerAdapter in class AbstractCacheAdapter<org.ehcache.event.CacheEventListener>
      Parameters:
      cacheEntryListener - The listener to create an adapter for
      Returns:
      an adapter that forwards notifications
    • doRegisterListener

      protected Registration doRegisterListener(org.ehcache.event.CacheEventListener listenerAdapter)
      Description copied from class: AbstractCacheAdapter
      Registers the given listener with the cache implementation
      Specified by:
      doRegisterListener in class AbstractCacheAdapter<org.ehcache.event.CacheEventListener>
      Parameters:
      listenerAdapter - the listener to register
      Returns:
      a handle to deregister the listener