@EachBean(value=RedisCacheConfiguration.class) @Requires(classes=io.micronaut.cache.SyncCache.class, property="redis.pool.enabled", defaultValue="false", notEquals="true") public class RedisCache extends AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
SyncCache
for Lettuce / Redis.Modifier and Type | Class and Description |
---|---|
protected class |
RedisCache.RedisAsyncCache
Redis Async cache implementation.
|
expireAfterAccess, expireAfterWritePolicy, INVALID_REDIS_CONNECTION_MESSAGE, keySerializer, redisCacheConfiguration, valueSerializer
Constructor and Description |
---|
RedisCache(DefaultRedisCacheConfiguration defaultRedisCacheConfiguration,
RedisCacheConfiguration redisCacheConfiguration,
io.micronaut.core.convert.ConversionService<?> conversionService,
io.micronaut.context.BeanLocator beanLocator)
Creates a new redis cache for the given arguments.
|
Modifier and Type | Method and Description |
---|---|
io.micronaut.cache.AsyncCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>> |
async() |
void |
close() |
<T> java.util.Optional<T> |
get(java.lang.Object key,
io.micronaut.core.type.Argument<T> requiredType) |
<T> T |
get(java.lang.Object key,
io.micronaut.core.type.Argument<T> requiredType,
java.util.function.Supplier<T> supplier) |
protected java.lang.String |
getKeysPattern() |
java.lang.String |
getName() |
io.lettuce.core.api.StatefulConnection<byte[],byte[]> |
getNativeCache() |
protected <T> java.util.Optional<T> |
getValue(io.micronaut.core.type.Argument<T> requiredType,
byte[] serializedKey)
Get the value based on the parameters.
|
void |
invalidate(java.lang.Object key) |
void |
invalidateAll() |
void |
put(java.lang.Object key,
java.lang.Object value) |
<T> java.util.Optional<T> |
putIfAbsent(java.lang.Object key,
T value) |
protected <T> void |
putValue(byte[] serializedKey,
T value)
Place the value in the cache.
|
protected byte[] |
serializeKey(java.lang.Object key)
Serialize the key.
|
get, getRedisKeyAsyncCommands, getRedisKeyCommands, getRedisStringAsyncCommands, getRedisStringCommands, putValue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public RedisCache(DefaultRedisCacheConfiguration defaultRedisCacheConfiguration, RedisCacheConfiguration redisCacheConfiguration, io.micronaut.core.convert.ConversionService<?> conversionService, io.micronaut.context.BeanLocator beanLocator)
defaultRedisCacheConfiguration
- The default configurationredisCacheConfiguration
- The configurationconversionService
- The conversion servicebeanLocator
- The bean locator used to discover the redis connection from the configurationpublic java.lang.String getName()
public io.lettuce.core.api.StatefulConnection<byte[],byte[]> getNativeCache()
public <T> T get(java.lang.Object key, io.micronaut.core.type.Argument<T> requiredType, java.util.function.Supplier<T> supplier)
public void invalidate(java.lang.Object key)
public void invalidateAll()
public io.micronaut.cache.AsyncCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>> async()
protected <T> java.util.Optional<T> getValue(io.micronaut.core.type.Argument<T> requiredType, byte[] serializedKey)
getValue
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
T
- type of the argumentrequiredType
- requiredTypeserializedKey
- serializedKeyprotected <T> void putValue(byte[] serializedKey, T value)
putValue
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
T
- type of the valueserializedKey
- serializedKeyvalue
- value@NonNull public <T> java.util.Optional<T> get(java.lang.Object key, io.micronaut.core.type.Argument<T> requiredType)
get
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
get
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
public void put(java.lang.Object key, java.lang.Object value)
put
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
put
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
@NonNull public <T> java.util.Optional<T> putIfAbsent(java.lang.Object key, T value)
putIfAbsent
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
putIfAbsent
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
protected java.lang.String getKeysPattern()
getKeysPattern
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
protected byte[] serializeKey(java.lang.Object key)
AbstractRedisCache
serializeKey
in class AbstractRedisCache<io.lettuce.core.api.StatefulConnection<byte[],byte[]>>
key
- The key@PreDestroy public void close()