Class CaffeineCacheImpl
java.lang.Object
io.quarkus.cache.runtime.AbstractCache
io.quarkus.cache.runtime.caffeine.CaffeineCacheImpl
- All Implemented Interfaces:
Cache,CaffeineCache
This class is an internal Quarkus cache implementation using Caffeine. Do not use it explicitly from your Quarkus
application.
The public methods signatures may change without prior notice.
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class io.quarkus.cache.runtime.AbstractCache
NULL_KEYS_NOT_SUPPORTED_MSG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<K,V> io.smallrye.mutiny.Uni <V> Returns a lazy asynchronous action that will emit the cache value identified bykey, obtaining that value fromvalueLoaderif necessary.<K,V> io.smallrye.mutiny.Uni <V> Returns a lazy asynchronous action that will emit the cache value identified bykey, obtaining that value fromvalueLoaderif necessary.<V> CompletableFuture<V> getIfPresent(Object key) Returns the future associated withkeyin this cache, ornullif there is no cached future forkey.getName()Returns the cache name.longgetSize()io.smallrye.mutiny.Uni<Void> invalidate(Object key) Removes the cache entry identified bykeyfrom the cache.io.smallrye.mutiny.Uni<Void> Removes all entries from the cache.io.smallrye.mutiny.Uni<Void> invalidateIf(Predicate<Object> predicate) Removes all cache entries whose keys match the given predicate.keySet()Returns an unmodifiableSetview of the keys contained in this cache.<V> voidput(Object key, CompletableFuture<V> valueFuture) Associatesvaluewithkeyin this cache.voidsetExpireAfterAccess(Duration duration) Changes the duration, initially set from the configuration, after which each entry should be automatically removed from the cache once that duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.voidsetExpireAfterWrite(Duration duration) Changes the duration, initially set from the configuration, after which each entry should be automatically removed from the cache once that duration has elapsed after the entry's creation, or the most recent replacement of its value.voidsetMaximumSize(long maximumSize) Changes the maximum number of entries the cache may contain.Methods inherited from class io.quarkus.cache.runtime.AbstractCache
as, getDefaultKeyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.quarkus.cache.Cache
as, getDefaultKey
-
Field Details
-
cache
-
-
Constructor Details
-
CaffeineCacheImpl
-
-
Method Details
-
getName
Description copied from interface:CacheReturns the cache name. -
get
Description copied from interface:CacheReturns a lazy asynchronous action that will emit the cache value identified bykey, obtaining that value fromvalueLoaderif necessary. -
getAsync
public <K,V> io.smallrye.mutiny.Uni<V> getAsync(K key, Function<K, io.smallrye.mutiny.Uni<V>> valueLoader) Description copied from interface:CacheReturns a lazy asynchronous action that will emit the cache value identified bykey, obtaining that value fromvalueLoaderif necessary. -
getIfPresent
Description copied from interface:CaffeineCacheReturns the future associated withkeyin this cache, ornullif there is no cached future forkey. This method is delegating to theAsyncCache.getIfPresent(Object), while recording the cache stats if they are enabled.- Specified by:
getIfPresentin interfaceCaffeineCache- Parameters:
key- key whose associated value is to be returned- Returns:
- the future value to which the specified key is mapped, or
nullif this cache does not contain a mapping for the key - See Also:
-
invalidate
Description copied from interface:CacheRemoves the cache entry identified bykeyfrom the cache. If the key does not identify any cache entry, nothing will happen.- Specified by:
invalidatein interfaceCache- Parameters:
key- cache key
-
invalidateAll
Description copied from interface:CacheRemoves all entries from the cache.- Specified by:
invalidateAllin interfaceCache
-
invalidateIf
Description copied from interface:CacheRemoves all cache entries whose keys match the given predicate.- Specified by:
invalidateIfin interfaceCache- Parameters:
predicate-
-
keySet
Description copied from interface:CaffeineCacheReturns an unmodifiableSetview of the keys contained in this cache. If the cache entries are modified while an iteration over the set is in progress, the set will remain unchanged.- Specified by:
keySetin interfaceCaffeineCache- Returns:
- a set view of the keys contained in this cache
-
put
Description copied from interface:CaffeineCacheAssociatesvaluewithkeyin this cache. If the cache previously contained a value associated withkey, the old value is replaced byvalue. If the asynchronous computation fails, the entry will be automatically removed.Prefer
Cache.get(Object, Function)when using the conventional "if cached, return; otherwise create, cache and return" pattern.- Specified by:
putin interfaceCaffeineCache- Parameters:
key- key with which the specified value is to be associatedvalueFuture- value to be associated with the specified key
-
setExpireAfterWrite
Description copied from interface:CaffeineCacheChanges the duration, initially set from the configuration, after which each entry should be automatically removed from the cache once that duration has elapsed after the entry's creation, or the most recent replacement of its value.Warning: this method must not be invoked from within an atomic scope of a cache operation.
- Specified by:
setExpireAfterWritein interfaceCaffeineCache- Parameters:
duration- the length of time after which an entry should be automatically removed
-
setExpireAfterAccess
Description copied from interface:CaffeineCacheChanges the duration, initially set from the configuration, after which each entry should be automatically removed from the cache once that duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.Warning: this method must not be invoked from within an atomic scope of a cache operation.
- Specified by:
setExpireAfterAccessin interfaceCaffeineCache- Parameters:
duration- the length of time after which an entry should be automatically removed
-
setMaximumSize
public void setMaximumSize(long maximumSize) Description copied from interface:CaffeineCacheChanges the maximum number of entries the cache may contain.Warning: this method must not be invoked from within an atomic scope of a cache operation.
- Specified by:
setMaximumSizein interfaceCaffeineCache- Parameters:
maximumSize- the maximum size of the cache
-
getCacheInfo
-
getSize
public long getSize()
-