Class JCacheAdapter

java.lang.Object
org.axonframework.common.caching.AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration<Object,Object>>
org.axonframework.common.caching.JCacheAdapter
All Implemented Interfaces:
Cache

public class JCacheAdapter extends AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration<Object,Object>>
Cache adapter implementation that allows providers implementing the JCache abstraction to be used.
Since:
2.1.2
Author:
Allard Buijze
  • Constructor Details

    • JCacheAdapter

      public JCacheAdapter(javax.cache.Cache<Object,Object> jCache)
      Initialize the adapter to forward call to the given jCache instance
      Parameters:
      jCache - The cache to forward all 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 javax.cache.configuration.CacheEntryListenerConfiguration<Object,Object> 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<javax.cache.configuration.CacheEntryListenerConfiguration<Object,Object>>
      Parameters:
      cacheEntryListener - The listener to create an adapter for
      Returns:
      an adapter that forwards notifications
    • doRegisterListener

      protected Registration doRegisterListener(javax.cache.configuration.CacheEntryListenerConfiguration<Object,Object> listenerAdapter)
      Description copied from class: AbstractCacheAdapter
      Registers the given listener with the cache implementation
      Specified by:
      doRegisterListener in class AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration<Object,Object>>
      Parameters:
      listenerAdapter - the listener to register
      Returns:
      a handle to deregister the listener