Class CaffeineShadedProducerCacheProvider

java.lang.Object
org.apache.pulsar.reactive.client.producercache.CaffeineShadedProducerCacheProvider
All Implemented Interfaces:
AutoCloseable, org.apache.pulsar.reactive.client.adapter.ProducerCacheProvider

public class CaffeineShadedProducerCacheProvider extends Object implements org.apache.pulsar.reactive.client.adapter.ProducerCacheProvider
Producer cache provider that uses a shaded Caffeine AsyncCache to cache entries.
  • Constructor Details

    • CaffeineShadedProducerCacheProvider

      public CaffeineShadedProducerCacheProvider()
      Create a cache provider instance with default values.
    • CaffeineShadedProducerCacheProvider

      public CaffeineShadedProducerCacheProvider(Duration cacheExpireAfterAccess, Duration cacheExpireAfterWrite, Long cacheMaximumSize, Integer cacheInitialCapacity)
      Create a cache provider instance with the specified options.
      Parameters:
      cacheExpireAfterAccess - time period after last access to expire unused entries in the cache
      cacheExpireAfterWrite - time period after last write to expire unused entries in the cache
      cacheMaximumSize - maximum size of cache (entries)
      cacheInitialCapacity - the initial size of cache
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getOrCreateCachedEntry

      public <K, V> CompletableFuture<V> getOrCreateCachedEntry(K key, Function<K,CompletableFuture<V>> createEntryFunction)
      Specified by:
      getOrCreateCachedEntry in interface org.apache.pulsar.reactive.client.adapter.ProducerCacheProvider