Class CacheImpl<K,V>

java.lang.Object
io.github.resilience4j.cache.internal.CacheImpl<K,V>
All Implemented Interfaces:
Cache<K,V>

public class CacheImpl<K,V> extends Object implements Cache<K,V>
  • Field Details

  • Constructor Details

    • CacheImpl

      public CacheImpl(javax.cache.Cache<K,V> cache)
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface Cache<K,V>
      Returns:
      the cache name
    • getMetrics

      public Cache.Metrics getMetrics()
      Description copied from interface: Cache
      Returns the Metrics of this Cache.
      Specified by:
      getMetrics in interface Cache<K,V>
      Returns:
      the Metrics of this Cache
    • computeIfAbsent

      public V computeIfAbsent(K cacheKey, io.github.resilience4j.core.functions.CheckedSupplier<V> supplier)
      Description copied from interface: Cache
      If the key is not already associated with a cached value, attempts to compute its value using the given supplier and puts it into the cache. Otherwise it returns the cached value. If the function itself throws an (unchecked) exception, the exception is rethrown.
      Specified by:
      computeIfAbsent in interface Cache<K,V>
      Parameters:
      cacheKey - key with which the specified value is to be associated
      supplier - value to be associated with the specified key
      Returns:
      cached value
    • getValueFromCache

      private Optional<V> getValueFromCache(K cacheKey)
    • invokeSupplierAndStore

      private V invokeSupplierAndStore(K cacheKey, io.github.resilience4j.core.functions.CheckedSupplier<V> supplier)
    • onError

      private void onError(Throwable throwable)
    • onCacheMiss

      private void onCacheMiss(K cacheKey)
    • onCacheHit

      private void onCacheHit(K cacheKey)
    • publishCacheEvent

      private void publishCacheEvent(Supplier<CacheEvent> event)
    • getEventPublisher

      public Cache.EventPublisher getEventPublisher()
      Description copied from interface: Cache
      Returns an EventPublisher which can be used to register event consumers.
      Specified by:
      getEventPublisher in interface Cache<K,V>
      Returns:
      an EventPublisher