Class CaffeineCacheProvider<K,V>
java.lang.Object
org.springframework.pulsar.cache.provider.caffeine.CaffeineCacheProvider<K,V>
- Type Parameters:
K- the type of cache keyV- the type of cache entries
- All Implemented Interfaces:
CacheProvider<K,V>
Cache provider implementation backed by a
Caffeine cache.- Author:
- Chris Bono
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasMap()Returns a view of the entries stored in the cache as a thread-safe map.getOrCreateIfAbsent(K cacheKey, Function<K, V> createEntryFunction) Returns the value associated with thekeyin the cache.voidinvalidateAll(BiConsumer<K, V> onInvalidateEntry) Discards all entries in the cache and calls theonInvalidateEntrycallback (if provided) for each entry.
-
Constructor Details
-
CaffeineCacheProvider
-
-
Method Details
-
getOrCreateIfAbsent
Description copied from interface:CacheProviderReturns the value associated with thekeyin the cache.If the key is not already associated with an entry in the cache, the
createEntryFunctionis used to compute the value to cache and return.- Specified by:
getOrCreateIfAbsentin interfaceCacheProvider<K,V> - Parameters:
cacheKey- the cache keycreateEntryFunction- the function to compute a value- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
-
asMap
Description copied from interface:CacheProviderReturns a view of the entries stored in the cache as a thread-safe map. Modifications made to the map directly affect the cache.- Specified by:
asMapin interfaceCacheProvider<K,V> - Returns:
- a thread-safe view of the cache supporting all optional
Mapoperations
-
invalidateAll
Description copied from interface:CacheProviderDiscards all entries in the cache and calls theonInvalidateEntrycallback (if provided) for each entry.- Specified by:
invalidateAllin interfaceCacheProvider<K,V> - Parameters:
onInvalidateEntry- callback invoked for each invalidated entry
-