Package io.micronaut.cache
Class AbstractMapBasedSyncCache<C extends Map<Object,Object>> 
java.lang.Object
io.micronaut.cache.AbstractMapBasedSyncCache<C>
- Type Parameters:
 C- the native cache object, such thatC extends Map.
- Direct Known Subclasses:
 HazelcastSyncCache,InfinispanSyncCache
public abstract class AbstractMapBasedSyncCache<C extends Map<Object,Object>> 
extends Object
implements SyncCache<C>
- Since:
 - 1.3.0
 - Author:
 - Álvaro Sánchez-Mariscal
 
- 
Constructor Summary
ConstructorsConstructorDescriptionAbstractMapBasedSyncCache(io.micronaut.core.convert.ConversionService conversionService, C nativeCache)  - 
Method Summary
Modifier and TypeMethodDescription<T> Optional<T>Resolve the given value for the given key.<T> TResolve the given value for the given key.io.micronaut.core.convert.ConversionServiceabstract StringgetName()voidinvalidate(Object key) Invalidate the value for the given key.voidInvalidate all cached values within this cache.voidCache the specified value using the specified key.<T> TputIfAbsent(Object key, Supplier<T> value) Cache the supplied value using the specified key if it is not already present.<T> Optional<T>putIfAbsent(Object key, T value) Cache the specified value using the specified key if it is not already present.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.cache.Cache
getCacheInfoMethods inherited from interface io.micronaut.cache.SyncCache
async, get, get, getExecutorService 
- 
Constructor Details
- 
AbstractMapBasedSyncCache
public AbstractMapBasedSyncCache(io.micronaut.core.convert.ConversionService conversionService, C nativeCache) - Parameters:
 conversionService- the conversion servicenativeCache- the native cache
 
 - 
 - 
Method Details
- 
getConversionService
public io.micronaut.core.convert.ConversionService getConversionService()- Returns:
 - The conversion service
 
 - 
get
@NonNull public <T> Optional<T> get(@NonNull Object key, @NonNull io.micronaut.core.type.Argument<T> requiredType) Description copied from interface:SyncCacheResolve the given value for the given key. - 
get
public <T> T get(@NonNull Object key, @NonNull io.micronaut.core.type.Argument<T> requiredType, @NonNull Supplier<T> supplier) Description copied from interface:SyncCacheResolve the given value for the given key. If the value is not found the specifiedSupplierwill be invoked and the return value cached.- Specified by:
 getin interfaceSyncCache<C extends Map<Object,Object>> - Type Parameters:
 T- The concrete type- Parameters:
 key- The cache keyrequiredType- The required typesupplier- The supplier that should be invoked if the value is not found- Returns:
 - An optional containing the value if it exists and is able to be converted to the specified type
 
 - 
putIfAbsent
Description copied from interface:SyncCacheCache the specified value using the specified key if it is not already present.
- Specified by:
 putIfAbsentin interfaceSyncCache<C extends Map<Object,Object>> - Type Parameters:
 T- The concrete type- Parameters:
 key- the key with which the specified value is to be associatedvalue- the value to be associated with the specified key- Returns:
 - An optional of the existing value or 
Optional.empty()if the specified value parameter was cached 
 - 
putIfAbsent
Description copied from interface:SyncCacheCache the supplied value using the specified key if it is not already present.
- Specified by:
 putIfAbsentin interfaceSyncCache<C extends Map<Object,Object>> - Type Parameters:
 T- The concrete type- Parameters:
 key- the key with which the specified value is to be associatedvalue- the value supplier to be associated with the specified key- Returns:
 - An optional of the existing value or the new value returned by the supplier
 
 - 
put
Description copied from interface:SyncCacheCache the specified value using the specified key.
 - 
invalidate
Description copied from interface:SyncCacheInvalidate the value for the given key. - 
invalidateAll
public void invalidateAll()Description copied from interface:SyncCacheInvalidate all cached values within this cache. - 
getName
 - 
getNativeCache
 
 -