@EachBean(value=RedisCacheConfiguration.class) @Requires(classes=io.micronaut.cache.SyncCache.class) public class RedisCache extends java.lang.Object implements io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>, java.lang.AutoCloseable
SyncCache for Lettuce / Redis.| Modifier and Type | Class and Description |
|---|---|
protected class |
RedisCache.RedisAsyncCache
Redis Async cache implementation.
|
| 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<?,?>> |
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<?,?> |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic 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()
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> 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<?,?>>public <T> T get(java.lang.Object key,
io.micronaut.core.type.Argument<T> requiredType,
java.util.function.Supplier<T> supplier)
get in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>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<?,?>>public void put(java.lang.Object key,
java.lang.Object value)
put in interface io.micronaut.cache.SyncCache<io.lettuce.core.api.StatefulConnection<?,?>>public void invalidate(java.lang.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> java.util.Optional<T> getValue(io.micronaut.core.type.Argument<T> requiredType,
byte[] serializedKey)
T - type of the argumentrequiredType - requiredTypeserializedKey - serializedKeyprotected java.lang.String getKeysPattern()
protected <T> void putValue(byte[] serializedKey,
T value)
T - type of the valueserializedKey - serializedKeyvalue - valueprotected byte[] serializeKey(java.lang.Object key)
key - The key@PreDestroy public void close()
close in interface java.lang.AutoCloseable