public class RedisCacheConfiguration extends Object
RedisCacheConfiguration helps customizing RedisCache behaviour such as caching
null values, cache key prefixes and binary serialization. defaultCacheConfig() and customize RedisCache behaviour from there
on.public static RedisCacheConfiguration defaultCacheConfig()
RedisCacheConfiguration using the following:
StringRedisSerializerJdkSerializationRedisSerializerDefaultFormattingConversionService with default
cache key convertersRedisCacheConfiguration.public static RedisCacheConfiguration defaultCacheConfig(@Nullable ClassLoader classLoader)
RedisCacheConfiguration given ClassLoader using the following:
StringRedisSerializerJdkSerializationRedisSerializerDefaultFormattingConversionService with default
cache key convertersclassLoader - the ClassLoader used for deserialization by the
JdkSerializationRedisSerializer.RedisCacheConfiguration.public RedisCacheConfiguration entryTtl(Duration ttl)
Duration.ZERO to declare an eternal cache.ttl - must not be null.RedisCacheConfiguration.@Deprecated public RedisCacheConfiguration prefixKeysWith(String prefix)
prefixCacheNameWith(String) or computePrefixWith(CacheKeyPrefix)
instead.prefix therefore we recommend rather using
prefixCacheNameWith(String) or computePrefixWith(CacheKeyPrefix) for more control. prefix + cache entry key.prefix - must not be null.RedisCacheConfiguration.public RedisCacheConfiguration prefixCacheNameWith(String prefix)
cache name with the given value. prefix + cache name + "::" + cache entry key.prefix - the prefix to prepend to the cache name.computePrefixWith(CacheKeyPrefix),
CacheKeyPrefix.prefixed(String)public RedisCacheConfiguration computePrefixWith(CacheKeyPrefix cacheKeyPrefix)
CacheKeyPrefix to compute the prefix for the actual Redis key given the
cache name as function input.cacheKeyPrefix - must not be null.RedisCacheConfiguration.CacheKeyPrefixpublic RedisCacheConfiguration disableCachingNullValues()
Cache.put(Object, Object) operation involving
null value will error. Nothing will be written to Redis, nothing will be removed. An already existing
key will still be there afterwards with the very same value as before.RedisCacheConfiguration.public RedisCacheConfiguration disableKeyPrefix()
Cache.clear() might result in unintended removal of keys in Redis. Make
sure to use a dedicated Redis instance when disabling prefixes.RedisCacheConfiguration.public RedisCacheConfiguration withConversionService(ConversionService conversionService)
ConversionService used for cache key to String conversion.conversionService - must not be null.RedisCacheConfiguration.public RedisCacheConfiguration serializeKeysWith(RedisSerializationContext.SerializationPair<String> keySerializationPair)
RedisSerializationContext.SerializationPair used for de-/serializing cache keys.keySerializationPair - must not be null.RedisCacheConfiguration.public RedisCacheConfiguration serializeValuesWith(RedisSerializationContext.SerializationPair<?> valueSerializationPair)
RedisSerializationContext.SerializationPair used for de-/serializing cache values.valueSerializationPair - must not be null.RedisCacheConfiguration.@Deprecated public Optional<String> getKeyPrefix()
getKeyPrefixFor(String).public String getKeyPrefixFor(String cacheName)
public boolean usePrefix()
getKeyPrefixFor(String) if present or
the default which resolves to Cache.getName().public boolean getAllowCacheNullValues()
public RedisSerializationContext.SerializationPair<String> getKeySerializationPair()
public RedisSerializationContext.SerializationPair<Object> getValueSerializationPair()
public Duration getTtl()
public ConversionService getConversionService()
ConversionService used for cache key to String conversion. Never null.public void addCacheKeyConverter(Converter<?,String> cacheKeyConverter)
Converter for extracting the String representation of a cache key if no suitable
Object.toString() method is present.cacheKeyConverter - IllegalStateException - if getConversionService() does not allow converter registration.public void configureKeyConverters(Consumer<ConverterRegistry> registryConsumer)
registryConsumer - never null.IllegalStateException - if getConversionService() does not allow converter registration.public static void registerDefaultConverters(ConverterRegistry registry)
registry - must not be null.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.