Class NoCache

java.lang.Object
org.axonframework.common.caching.NoCache
All Implemented Interfaces:
Cache

public final class NoCache extends Object implements Cache
Cache implementation that does absolutely nothing. Objects aren't cached, making it a special case implementation for the case when caching is disabled.
Since:
0.3
Author:
Allard Buijze
  • Field Details

    • INSTANCE

      public static final NoCache INSTANCE
      Creates a singleton reference the NoCache implementation.
  • 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
      Specified by:
      get in interface Cache
      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.
      Specified by:
      put in interface Cache
      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.
      Specified by:
      putIfAbsent in interface Cache
      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.
    • computeIfAbsent

      public <T> T computeIfAbsent(Object key, Supplier<T> valueSupplier)
      Description copied from interface: Cache
      Returns the value under the given key in the cache. If there is no value present, will invoke the given valueSupplier, put the value in the cache and return the produced value.
      Specified by:
      computeIfAbsent in interface Cache
      Parameters:
      key - The key under which the item was cached. If not present, this key is used to cache the outcome of the valueSupplier.
      valueSupplier - A supplier that lazily supplies the value if there's no key present.
      Returns:
      The value that is in the cache after the operation. This can be the original value or the one supplied by the valueSupplier.
    • 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.
      Specified by:
      remove in interface Cache
      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.
      Specified by:
      removeAll in interface Cache
    • containsKey

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

      public Registration registerCacheEntryListener(Cache.EntryListener cacheEntryListener)
      Description copied from interface: Cache
      Registers the given cacheEntryListener to listen for Cache changes.
      Specified by:
      registerCacheEntryListener in interface Cache
      Parameters:
      cacheEntryListener - The listener to register
      Returns:
      a handle to deregister the listener
    • 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.
      Specified by:
      computeIfPresent in interface Cache
      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.