@EachBean(value=CacheConfiguration.class) public class DefaultSyncCache extends Object implements SyncCache<com.github.benmanes.caffeine.cache.Cache>
A default SyncCache implementation based on Caffeine
Since Caffeine is a non-blocking in-memory cache the SyncCache.async() method will return an implementation that
runs operations in the current thread.
| Constructor and Description |
|---|
DefaultSyncCache(CacheConfiguration cacheConfiguration,
ApplicationContext applicationContext,
ConversionService<?> conversionService)
Construct a sync cache implementation with given configurations.
|
DefaultSyncCache(DefaultCacheConfiguration cacheConfiguration,
ApplicationContext applicationContext,
ConversionService<?> conversionService)
Construct a sync cache implementation with given configurations.
|
| Modifier and Type | Method and Description |
|---|---|
protected com.github.benmanes.caffeine.cache.Cache |
buildCache(CacheConfiguration cacheConfiguration)
Build a cache from the given configurations.
|
<T> Optional<T> |
get(Object key,
Argument<T> requiredType)
Resolve the given value for the given key.
|
<T> T |
get(Object key,
Argument<T> requiredType,
Supplier<T> supplier)
Resolve the given value for the given key.
|
Publisher<CacheInfo> |
getCacheInfo() |
String |
getName() |
com.github.benmanes.caffeine.cache.Cache |
getNativeCache() |
void |
invalidate(Object key)
Invalidate the value for the given key.
|
void |
invalidateAll()
Invalidate all cached values within this cache.
|
void |
put(Object key,
Object value)
Cache the specified value using the specified key.
|
<T> Optional<T> |
putIfAbsent(Object key,
T value)
Cache the specified value using the specified key if it is not already present.
|
public DefaultSyncCache(DefaultCacheConfiguration cacheConfiguration, ApplicationContext applicationContext, ConversionService<?> conversionService)
cacheConfiguration - The cache configurationsapplicationContext - The application contextconversionService - To convert the value from the cache into given required type@Inject public DefaultSyncCache(CacheConfiguration cacheConfiguration, ApplicationContext applicationContext, ConversionService<?> conversionService)
cacheConfiguration - The cache configurationsapplicationContext - The application contextconversionService - To convert the value from the cache into given required typepublic Publisher<CacheInfo> getCacheInfo()
getCacheInfo in interface Cache<com.github.benmanes.caffeine.cache.Cache>public String getName()
public com.github.benmanes.caffeine.cache.Cache getNativeCache()
getNativeCache in interface Cache<com.github.benmanes.caffeine.cache.Cache>public <T> Optional<T> get(Object key, Argument<T> requiredType)
SyncCachepublic <T> T get(Object key, Argument<T> requiredType, Supplier<T> supplier)
SyncCacheSupplier will
be invoked and the return value cached.get in interface SyncCache<com.github.benmanes.caffeine.cache.Cache>T - The concrete typekey - The cache keyrequiredType - The required typesupplier - The supplier that should be invoked if the value is not foundpublic void invalidate(Object key)
SyncCacheinvalidate in interface SyncCache<com.github.benmanes.caffeine.cache.Cache>key - The key to invalidpublic void invalidateAll()
SyncCacheinvalidateAll in interface SyncCache<com.github.benmanes.caffeine.cache.Cache>public void put(Object key, Object value)
SyncCacheCache the specified value using the specified key.
public <T> Optional<T> putIfAbsent(Object key, T value)
SyncCacheCache the specified value using the specified key if it is not already present.
putIfAbsent in interface SyncCache<com.github.benmanes.caffeine.cache.Cache>T - The concrete typekey - the key with which the specified value is to be associatedvalue - the value to be associated with the specified keyOptional.empty() if the specified value parameter was cachedprotected com.github.benmanes.caffeine.cache.Cache buildCache(CacheConfiguration cacheConfiguration)
cacheConfiguration - The cache configurations