@EachBean(value=RedisCacheConfiguration.class) public class RedisCache extends Object implements io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
SyncCache
for Lettuce / Redis.Modifier and Type | Class and Description |
---|---|
protected class |
RedisCache.RedisAsyncCache
Redis Async cache implementation.
|
Constructor and Description |
---|
RedisCache(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<?,?>> |
async() |
protected AsyncCacheCommands |
asyncCommands(io.lettuce.core.api.StatefulConnection<String,String> connection)
Get the asynchronous commands for the stateful connection.
|
<T> Optional<T> |
get(Object key,
io.micronaut.core.type.Argument<T> requiredType) |
<T> T |
get(Object key,
io.micronaut.core.type.Argument<T> requiredType,
Supplier<T> supplier) |
protected String |
getKeysPattern() |
String |
getName() |
io.lettuce.core.api.StatefulConnection<?,?> |
getNativeCache() |
protected <T> Optional<T> |
getValue(io.micronaut.core.type.Argument<T> requiredType,
SyncCacheCommands commands,
byte[] serializedKey)
Get the value based on the parameters.
|
void |
invalidate(Object key) |
void |
invalidateAll() |
void |
put(Object key,
Object value) |
<T> Optional<T> |
putIfAbsent(Object key,
T value) |
protected <T> void |
putValue(SyncCacheCommands commands,
byte[] serializedKey,
T value)
Place the value in the cache.
|
protected byte[] |
serializeKey(Object key)
Serialize the key.
|
protected SyncCacheCommands |
syncCommands(io.lettuce.core.api.StatefulConnection<String,String> connection)
Get the synchronous commands for the stateful connection.
|
public RedisCache(RedisCacheConfiguration redisCacheConfiguration, io.micronaut.core.convert.ConversionService<?> conversionService, io.micronaut.context.BeanLocator beanLocator)
redisCacheConfiguration
- The configurationconversionService
- The conversion servicebeanLocator
- The bean locator used to discover the redis connection from the configurationpublic String getName()
getName
in interface io.micronaut.cache.Cache<io.lettuce.core.api.StatefulConnection<?,?>>
public io.lettuce.core.api.StatefulConnection<?,?> getNativeCache()
getNativeCache
in interface io.micronaut.cache.Cache<io.lettuce.core.api.StatefulConnection<?,?>>
public <T> Optional<T> get(Object key, io.micronaut.core.type.Argument<T> requiredType)
get
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
public <T> T get(Object key, io.micronaut.core.type.Argument<T> requiredType, Supplier<T> supplier)
get
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
public <T> Optional<T> putIfAbsent(Object key, T value)
putIfAbsent
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
public void put(Object key, Object value)
put
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
public void invalidate(Object key)
invalidate
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
public void invalidateAll()
invalidateAll
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
public io.micronaut.cache.AsyncCache<io.lettuce.core.api.StatefulConnection<?,?>> async()
async
in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>
protected <T> Optional<T> getValue(io.micronaut.core.type.Argument<T> requiredType, SyncCacheCommands commands, byte[] serializedKey)
T
- type of the argumentrequiredType
- requiredTypecommands
- commandsserializedKey
- serializedKeyprotected String getKeysPattern()
protected <T> void putValue(SyncCacheCommands commands, byte[] serializedKey, T value)
T
- type of the valuecommands
- commandsserializedKey
- serializedKeyvalue
- valueprotected byte[] serializeKey(Object key)
key
- The keyprotected SyncCacheCommands syncCommands(io.lettuce.core.api.StatefulConnection<String,String> connection)
connection
- stateful connectionprotected AsyncCacheCommands asyncCommands(io.lettuce.core.api.StatefulConnection<String,String> connection)
connection
- stateful connection