Class RedisConnectionPoolCache
java.lang.Object
io.micronaut.configuration.lettuce.cache.AbstractRedisCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>>
io.micronaut.configuration.lettuce.cache.RedisConnectionPoolCache
- All Implemented Interfaces:
io.micronaut.cache.Cache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>>, io.micronaut.cache.SyncCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[], byte[]>>>, AutoCloseable
@EachBean(RedisCacheConfiguration.class)
@Requires(property="redis.enabled",notEquals="false") @Requires(classes=io.micronaut.cache.SyncCache.class,property="redis.pool.enabled",defaultValue="false",notEquals="false")
public class RedisConnectionPoolCache
extends AbstractRedisCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>>
An implementation of
SyncCache for Lettuce / Redis using connection pooling.- Since:
- 5.3.0
- Author:
- Graeme Rocher, Kovalov Illia
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classRedis Async cache implementation. -
Field Summary
Fields inherited from class AbstractRedisCache
expireAfterAccess, expireAfterWritePolicy, INVALID_REDIS_CONNECTION_MESSAGE, invalidateScanCount, keyPrefix, keySerializer, redisCacheConfiguration, valueSerializer -
Constructor Summary
ConstructorsConstructorDescriptionRedisConnectionPoolCache(DefaultRedisCacheConfiguration defaultRedisCacheConfiguration, RedisCacheConfiguration redisCacheConfiguration, io.micronaut.core.convert.ConversionService conversionService, io.micronaut.context.BeanLocator beanLocator, io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[], byte[]>> asyncPool) Creates a new redis cache for the given arguments. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.cache.AsyncCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[], byte[]>>> async()voidclose()<T> Tget(@NonNull Object key, @NonNull io.micronaut.core.type.Argument<T> requiredType, @NonNull Supplier<T> supplier) getAll(@NonNull Collection<K> keys) Resolve the values for the given keys.<K,T> @NonNull Map <K, T> getAll(@NonNull Collection<K> keys, @NonNull io.micronaut.core.type.Argument<T> requiredType) Resolve the values for the given keys.getName()io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[], byte[]>> protected <T> Optional<T> getValue(io.micronaut.core.type.Argument<T> requiredType, byte[] serializedKey) Get the value based on the parameters.voidinvalidate(Object key) voidvoidinvalidateAllKeys(@NonNull Collection<?> keys) Invalidate the values for the given keys.voidCache the specified values in bulk.protected <T> voidputValue(byte[] serializedKey, T value) Place the value in the cache.Methods inherited from class AbstractRedisCache
allKeys, allKeys, allKeys, allKeys, executeInsert, executeInsertAsync, executeRead, executeReadAsync, get, get, getKeysPattern, getRedisKeyAsyncCommands, getRedisKeyCommands, getRedisStringAsyncCommands, getRedisStringCommands, getValues, invalidateValues, put, putIfAbsent, putValue, putValues, serializeKeyMethods inherited from class 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
get, get, getExecutorService, putIfAbsent
-
Constructor Details
-
RedisConnectionPoolCache
public RedisConnectionPoolCache(DefaultRedisCacheConfiguration defaultRedisCacheConfiguration, RedisCacheConfiguration redisCacheConfiguration, io.micronaut.core.convert.ConversionService conversionService, io.micronaut.context.BeanLocator beanLocator, @Named("redisCacheAsyncPool") io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[], byte[]>> asyncPool) Creates a new redis cache for the given arguments.- Parameters:
defaultRedisCacheConfiguration- The default configurationredisCacheConfiguration- The configurationconversionService- The conversion servicebeanLocator- The bean locator used to discover the redis connection from the configurationasyncPool- Redis async pool
-
-
Method Details
-
getName
-
getNativeCache
public io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>> getNativeCache() -
get
-
getAll
Resolve the values for the given keys.- Type Parameters:
K- The key type- Parameters:
keys- The cache keys- Returns:
- An ordered map containing all requested keys
-
getAll
public <K,T> @NonNull Map<K,T> getAll(@NonNull Collection<K> keys, @NonNull io.micronaut.core.type.Argument<T> requiredType) Resolve the values for the given keys.- Type Parameters:
K- The key typeT- The value type- Parameters:
keys- The cache keysrequiredType- The required type- Returns:
- An ordered map containing all requested keys
-
putAll
Cache the specified values in bulk.- Parameters:
values- The values to cache
-
invalidate
-
invalidateAllKeys
Invalidate the values for the given keys.- Parameters:
keys- The keys to invalidate
-
invalidateAll
public void invalidateAll() -
async
public io.micronaut.cache.AsyncCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>> async() -
getValue
protected <T> Optional<T> getValue(io.micronaut.core.type.Argument<T> requiredType, byte[] serializedKey) Get the value based on the parameters.- Specified by:
getValuein classAbstractRedisCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>> - Type Parameters:
T- type of the argument- Parameters:
requiredType- requiredTypeserializedKey- serializedKey- Returns:
- value
-
putValue
protected <T> void putValue(byte[] serializedKey, T value) Place the value in the cache.- Specified by:
putValuein classAbstractRedisCache<io.lettuce.core.support.AsyncPool<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>> - Type Parameters:
T- type of the value- Parameters:
serializedKey- serializedKeyvalue- value
-
close
@PreDestroy public void close()
-