Class AbstractRedisCache<C>
java.lang.Object
io.micronaut.configuration.lettuce.cache.AbstractRedisCache<C>
- Type Parameters:
C
- – The native cache implementation
- All Implemented Interfaces:
io.micronaut.cache.Cache<C>
,io.micronaut.cache.SyncCache<C>
,AutoCloseable
- Direct Known Subclasses:
RedisCache
,RedisConnectionPoolCache
public abstract class AbstractRedisCache<C>
extends Object
implements io.micronaut.cache.SyncCache<C>, AutoCloseable
An abstract class implementing SyncCache for the redis.
- Since:
- 5.3.0
- Author:
- Graeme Rocher, Kovalov Illia
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Long
protected final ExpirationAfterWritePolicy
static final String
protected final Long
protected final io.micronaut.core.serialize.ObjectSerializer
protected final RedisCacheConfiguration
protected final io.micronaut.core.serialize.ObjectSerializer
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractRedisCache
(DefaultRedisCacheConfiguration defaultRedisCacheConfiguration, RedisCacheConfiguration redisCacheConfiguration, io.micronaut.core.convert.ConversionService conversionService, io.micronaut.context.BeanLocator beanLocator) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> T
get
(byte[] key, io.micronaut.core.type.Argument<T> requiredType, Supplier<T> supplier, io.lettuce.core.api.sync.RedisStringCommands<byte[], byte[]> commands) <T> Optional<T>
protected String
protected io.lettuce.core.api.async.RedisKeyAsyncCommands<byte[],
byte[]> getRedisKeyAsyncCommands
(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) protected io.lettuce.core.api.sync.RedisKeyCommands<byte[],
byte[]> getRedisKeyCommands
(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) protected io.lettuce.core.api.async.RedisStringAsyncCommands<byte[],
byte[]> getRedisStringAsyncCommands
(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) protected io.lettuce.core.api.sync.RedisStringCommands<byte[],
byte[]> getRedisStringCommands
(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) protected abstract <T> Optional<T>
getValue
(io.micronaut.core.type.Argument<T> requiredType, byte[] serializedKey) void
<T> Optional<T>
putIfAbsent
(Object key, T value) protected <T> void
putValue
(byte[] serializedKey, Optional<byte[]> serialized, ExpirationAfterWritePolicy policy, io.lettuce.core.api.sync.RedisStringCommands<byte[], byte[]> redisStringCommands, io.lettuce.core.api.sync.RedisKeyCommands<byte[], byte[]> redisKeyCommands, T value) protected abstract <T> void
putValue
(byte[] serializedKey, T value) protected byte[]
serializeKey
(Object key) Serialize the key.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
Methods inherited from interface io.micronaut.cache.Cache
getCacheInfo, getName, getNativeCache
Methods inherited from interface io.micronaut.cache.SyncCache
async, get, get, get, getExecutorService, invalidate, invalidateAll, putIfAbsent
-
Field Details
-
INVALID_REDIS_CONNECTION_MESSAGE
- See Also:
-
keySerializer
protected final io.micronaut.core.serialize.ObjectSerializer keySerializer -
valueSerializer
protected final io.micronaut.core.serialize.ObjectSerializer valueSerializer -
redisCacheConfiguration
-
expireAfterWritePolicy
-
expireAfterAccess
-
invalidateScanCount
-
-
Constructor Details
-
AbstractRedisCache
protected AbstractRedisCache(DefaultRedisCacheConfiguration defaultRedisCacheConfiguration, RedisCacheConfiguration redisCacheConfiguration, io.micronaut.core.convert.ConversionService conversionService, io.micronaut.context.BeanLocator beanLocator)
-
-
Method Details
-
get
- Specified by:
get
in interfaceio.micronaut.cache.SyncCache<C>
-
put
- Specified by:
put
in interfaceio.micronaut.cache.SyncCache<C>
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceio.micronaut.cache.SyncCache<C>
-
get
protected <T> T get(byte[] key, io.micronaut.core.type.Argument<T> requiredType, Supplier<T> supplier, io.lettuce.core.api.sync.RedisStringCommands<byte[], byte[]> commands) - Type Parameters:
T
-- Parameters:
key
-requiredType
-supplier
-commands
-- Returns:
- value from the cache
-
getRedisStringAsyncCommands
protected io.lettuce.core.api.async.RedisStringAsyncCommands<byte[],byte[]> getRedisStringAsyncCommands(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) - Parameters:
connection
-- Returns:
- RedisStringAsyncCommands
-
getRedisKeyAsyncCommands
protected io.lettuce.core.api.async.RedisKeyAsyncCommands<byte[],byte[]> getRedisKeyAsyncCommands(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) - Parameters:
connection
-- Returns:
- RedisKeyAsyncCommands
-
getRedisStringCommands
protected io.lettuce.core.api.sync.RedisStringCommands<byte[],byte[]> getRedisStringCommands(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) - Parameters:
connection
-- Returns:
- RedisStringCommands
-
getRedisKeyCommands
protected io.lettuce.core.api.sync.RedisKeyCommands<byte[],byte[]> getRedisKeyCommands(io.lettuce.core.api.StatefulConnection<byte[], byte[]> connection) - Parameters:
connection
-- Returns:
- RedisKeyCommands
-
getValue
protected abstract <T> Optional<T> getValue(io.micronaut.core.type.Argument<T> requiredType, byte[] serializedKey) - Type Parameters:
T
-- Parameters:
requiredType
-serializedKey
-- Returns:
- Optional
-
putValue
protected abstract <T> void putValue(byte[] serializedKey, T value) - Type Parameters:
T
-- Parameters:
serializedKey
-value
-
-
putValue
protected <T> void putValue(byte[] serializedKey, Optional<byte[]> serialized, ExpirationAfterWritePolicy policy, io.lettuce.core.api.sync.RedisStringCommands<byte[], byte[]> redisStringCommands, io.lettuce.core.api.sync.RedisKeyCommands<byte[], byte[]> redisKeyCommands, T value) - Type Parameters:
T
-- Parameters:
serializedKey
-serialized
-policy
-redisStringCommands
-redisKeyCommands
-value
-
-
getKeysPattern
- Returns:
- The default keys pattern.
-
serializeKey
Serialize the key.- Parameters:
key
- The key- Returns:
- bytes of the object
-