C
- the native cache object, such that C extends Map
.public abstract class AbstractMapBasedSyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>> extends java.lang.Object implements SyncCache<C>
SyncCache
implementation that relies on a cache object that implements the Map
interface.Constructor and Description |
---|
AbstractMapBasedSyncCache(io.micronaut.core.convert.ConversionService<?> conversionService,
C nativeCache) |
Modifier and Type | Method and Description |
---|---|
<T> java.util.Optional<T> |
get(java.lang.Object key,
io.micronaut.core.type.Argument<T> requiredType)
Resolve the given value for the given key.
|
<T> T |
get(java.lang.Object key,
io.micronaut.core.type.Argument<T> requiredType,
java.util.function.Supplier<T> supplier)
Resolve the given value for the given key.
|
io.micronaut.core.convert.ConversionService<?> |
getConversionService() |
abstract java.lang.String |
getName() |
C |
getNativeCache() |
void |
invalidate(java.lang.Object key)
Invalidate the value for the given key.
|
void |
invalidateAll()
Invalidate all cached values within this cache.
|
void |
put(java.lang.Object key,
java.lang.Object value)
Cache the specified value using the specified key.
|
<T> T |
putIfAbsent(java.lang.Object key,
java.util.function.Supplier<T> value)
Cache the supplied value using the specified key if it is not already present.
|
<T> java.util.Optional<T> |
putIfAbsent(java.lang.Object key,
T value)
Cache the specified value using the specified key if it is not already present.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
async, get, get, getExecutorService
getCacheInfo
public AbstractMapBasedSyncCache(io.micronaut.core.convert.ConversionService<?> conversionService, C nativeCache)
conversionService
- the conversion servicenativeCache
- the native cachepublic io.micronaut.core.convert.ConversionService<?> getConversionService()
@NonNull public <T> java.util.Optional<T> get(@NonNull java.lang.Object key, @NonNull io.micronaut.core.type.Argument<T> requiredType)
SyncCache
get
in interface SyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>>
T
- The concrete typekey
- The cache keyrequiredType
- The required typepublic <T> T get(@NonNull java.lang.Object key, @NonNull io.micronaut.core.type.Argument<T> requiredType, @NonNull java.util.function.Supplier<T> supplier)
SyncCache
Supplier
will
be invoked and the return value cached.get
in interface SyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>>
T
- The concrete typekey
- The cache keyrequiredType
- The required typesupplier
- The supplier that should be invoked if the value is not found@NonNull public <T> java.util.Optional<T> putIfAbsent(@NonNull java.lang.Object key, @NonNull T value)
SyncCache
Cache the specified value using the specified key if it is not already present.
putIfAbsent
in interface SyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>>
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 cached@NonNull public <T> T putIfAbsent(@NonNull java.lang.Object key, @NonNull java.util.function.Supplier<T> value)
SyncCache
Cache the supplied value using the specified key if it is not already present.
putIfAbsent
in interface SyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>>
T
- The concrete typekey
- the key with which the specified value is to be associatedvalue
- the value supplier to be associated with the specified keypublic void put(@NonNull java.lang.Object key, @NonNull java.lang.Object value)
SyncCache
Cache the specified value using the specified key.
public void invalidate(@NonNull java.lang.Object key)
SyncCache
invalidate
in interface SyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>>
key
- The key to invalidpublic void invalidateAll()
SyncCache
invalidateAll
in interface SyncCache<C extends java.util.Map<java.lang.Object,java.lang.Object>>
public abstract java.lang.String getName()
public C getNativeCache()
getNativeCache
in interface Cache<C extends java.util.Map<java.lang.Object,java.lang.Object>>