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 Summary
ConstructorsConstructorDescriptionCreate a cache provider instance with default values.CaffeineShadedProducerCacheProvider(Duration cacheExpireAfterAccess, Duration cacheExpireAfterWrite, Long cacheMaximumSize, Integer cacheInitialCapacity) Create a cache provider instance with the specified options. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()<K,V> CompletableFuture<V> getOrCreateCachedEntry(K key, Function<K, CompletableFuture<V>> createEntryFunction)
-
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 cachecacheExpireAfterWrite- time period after last write to expire unused entries in the cachecacheMaximumSize- maximum size of cache (entries)cacheInitialCapacity- the initial size of cache
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getOrCreateCachedEntry
public <K,V> CompletableFuture<V> getOrCreateCachedEntry(K key, Function<K, CompletableFuture<V>> createEntryFunction) - Specified by:
getOrCreateCachedEntryin interfaceorg.apache.pulsar.reactive.client.adapter.ProducerCacheProvider
-