Package io.micronaut.cache.caffeine
Class DefaultSyncCache
java.lang.Object
io.micronaut.cache.caffeine.DefaultSyncCache
- All Implemented Interfaces:
io.micronaut.cache.Cache<com.github.benmanes.caffeine.cache.Cache>,io.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
@EachBean(io.micronaut.cache.CacheConfiguration.class)
public class DefaultSyncCache
extends Object
implements io.micronaut.cache.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.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSyncCache(io.micronaut.cache.CacheConfiguration cacheConfiguration, io.micronaut.context.ApplicationContext applicationContext, io.micronaut.core.convert.ConversionService conversionService) Construct a sync cache implementation with given configurations.DefaultSyncCache(DefaultCacheConfiguration cacheConfiguration, io.micronaut.context.ApplicationContext applicationContext, io.micronaut.core.convert.ConversionService conversionService) Construct a sync cache implementation with given configurations. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.github.benmanes.caffeine.cache.CachebuildCache(io.micronaut.cache.CacheConfiguration cacheConfiguration) Build a cache from the given configurations.<T> Optional<T><T> Torg.reactivestreams.Publisher<io.micronaut.cache.CacheInfo>getName()com.github.benmanes.caffeine.cache.Cachevoidinvalidate(Object key) voidvoidCache the specified value using the specified key.<T> TputIfAbsent(Object key, Supplier<T> value) <T> Optional<T>putIfAbsent(Object key, T value) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.cache.SyncCache
async, get, get, getExecutorService
-
Constructor Details
-
DefaultSyncCache
public DefaultSyncCache(DefaultCacheConfiguration cacheConfiguration, io.micronaut.context.ApplicationContext applicationContext, io.micronaut.core.convert.ConversionService conversionService) Construct a sync cache implementation with given configurations.- Parameters:
cacheConfiguration- The cache configurationsapplicationContext- The application contextconversionService- To convert the value from the cache into given required type
-
DefaultSyncCache
@Inject public DefaultSyncCache(io.micronaut.cache.CacheConfiguration cacheConfiguration, io.micronaut.context.ApplicationContext applicationContext, io.micronaut.core.convert.ConversionService conversionService) Construct a sync cache implementation with given configurations.- Parameters:
cacheConfiguration- The cache configurationsapplicationContext- The application contextconversionService- To convert the value from the cache into given required type
-
-
Method Details
-
getCacheInfo
public org.reactivestreams.Publisher<io.micronaut.cache.CacheInfo> getCacheInfo()- Specified by:
getCacheInfoin interfaceio.micronaut.cache.Cache<com.github.benmanes.caffeine.cache.Cache>
-
getName
- Specified by:
getNamein interfaceio.micronaut.cache.Cache<com.github.benmanes.caffeine.cache.Cache>
-
getNativeCache
public com.github.benmanes.caffeine.cache.Cache getNativeCache()- Specified by:
getNativeCachein interfaceio.micronaut.cache.Cache<com.github.benmanes.caffeine.cache.Cache>
-
get
- Specified by:
getin interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
-
get
- Specified by:
getin interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
-
invalidate
- Specified by:
invalidatein interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
-
invalidateAll
public void invalidateAll()- Specified by:
invalidateAllin interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
-
put
Cache the specified value using the specified key. If the value is null, it will call
invalidate(Object)passing the key- Specified by:
putin interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>- Parameters:
key- the key with which the specified value is to be associatedvalue- the value to be associated with the specified key
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceio.micronaut.cache.SyncCache<com.github.benmanes.caffeine.cache.Cache>
-
buildCache
protected com.github.benmanes.caffeine.cache.Cache buildCache(io.micronaut.cache.CacheConfiguration cacheConfiguration) Build a cache from the given configurations.- Parameters:
cacheConfiguration- The cache configurations- Returns:
- cache
-