io.quarkus.cache.CacheManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-cache Show documentation
Show all versions of quarkus-cache Show documentation
Enable application data caching in CDI beans
package io.quarkus.cache;
import java.util.Collection;
import java.util.Optional;
/**
*
* Use this interface to retrieve all existing {@link Cache} names 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
* {@link CacheName} annotation can also be used to inject and access a specific cache from its name.
*
*
* Code example:
*
*
* {@literal @}ApplicationScoped
* public class CachedService {
*
* {@literal @}Inject
* CacheManager cacheManager;
* String getExpensiveValue(Object key) {
* Cache cache = cacheManager.getCache("my-cache");
* {@code Uni} cacheValue = cache.get(key, () -> expensiveService.getValue(key));
* return cacheValue.await().indefinitely();
* }
* }
*
*
*/
public interface CacheManager {
/**
* Gets a collection of all cache names.
*
* @return names of all caches
*/
Collection getCacheNames();
/**
* Gets the cache identified by the given name.
*
* @param name cache name
* @return an {@link Optional} containing the identified cache if it exists, or an empty {@link Optional} otherwise
*/
Optional getCache(String name);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy