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
-
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 thekey
in the cache.void
invalidateAll
(BiConsumer<K, V> onInvalidateEntry) Discards all entries in the cache and calls theonInvalidateEntry
callback (if provided) for each entry.
-
Constructor Details
-
CaffeineCacheProvider
-
-
Method Details
-
getOrCreateIfAbsent
Description copied from interface:CacheProvider
Returns the value associated with thekey
in the cache.If the key is not already associated with an entry in the cache, the
createEntryFunction
is used to compute the value to cache and return.- Specified by:
getOrCreateIfAbsent
in 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:CacheProvider
Returns 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:
asMap
in interfaceCacheProvider<K,
V> - Returns:
- a thread-safe view of the cache supporting all optional
Map
operations
-
invalidateAll
Description copied from interface:CacheProvider
Discards all entries in the cache and calls theonInvalidateEntry
callback (if provided) for each entry.- Specified by:
invalidateAll
in interfaceCacheProvider<K,
V> - Parameters:
onInvalidateEntry
- callback invoked for each invalidated entry
-