Package io.quarkus.cache
Interface CacheManager
-
public interface CacheManagerUse this interface to retrieve all existing
Cachenames and interact with any cache programmatically e.g. store, retrieve or delete cache values. It shares the same caches collection the Quarkus caching annotations use. The@io.quarkus.cache.CacheNameannotation can also be used to inject and access a specific cache from its name.Code example:
@Singleton public class CachedService { private final CacheManager cacheManager; public CachedService(CacheManager cacheManager) { this.cacheManager = cacheManager; } String getExpensiveValue(Object key) { Cache cache = cacheManager.getCache("my-cache");Uni<String>cacheValue = cache.get(key, () -> expensiveService.getValue(key)); return cacheValue.await().indefinitely(); } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<Cache>getCache(String name)Gets the cache identified by the given name.Collection<String>getCacheNames()Gets a collection of all cache names.
-
-
-
Method Detail
-
getCacheNames
Collection<String> getCacheNames()
Gets a collection of all cache names.- Returns:
- names of all caches
-
-