@ConditionalOnClass(value=org.springframework.data.redis.core.RedisOperations.class)
@EnableConfigurationProperties(value=org.springframework.boot.autoconfigure.data.redis.RedisProperties.class)
@Configuration
public class RedisConfigRegister
extends org.springframework.cache.annotation.CachingConfigurerSupport
| 构造器和说明 |
|---|
RedisConfigRegister() |
| 限定符和类型 | 方法和说明 |
|---|---|
org.springframework.cache.interceptor.CacheErrorHandler |
errorHandler() |
org.springframework.cache.interceptor.KeyGenerator |
keyGenerator()
自定义缓存key生成策略,默认将使用该策略
使用方法 @Cacheable
|
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory |
lettuceConnectionFactory()
为RedisTemplate配置Redis连接工厂实现
LettuceConnectionFactory实现了RedisConnectionFactory接口
这里要注意的是,在构建LettuceConnectionFactory 时,如果不使用内置的destroyMethod,可能会导致Redis连接早于其它Bean被销毁
|
org.springframework.data.redis.cache.RedisCacheConfiguration |
redisCacheConfiguration()
设置 redis 数据默认过期时间,默认7天
设置@cacheable 序列化方式
|
@Bean public org.springframework.data.redis.cache.RedisCacheConfiguration redisCacheConfiguration()
@Bean public org.springframework.cache.interceptor.KeyGenerator keyGenerator()
keyGenerator 在接口中 org.springframework.cache.annotation.CachingConfigurerkeyGenerator 在类中 org.springframework.cache.annotation.CachingConfigurerSupport@Bean public org.springframework.cache.interceptor.CacheErrorHandler errorHandler()
errorHandler 在接口中 org.springframework.cache.annotation.CachingConfigurererrorHandler 在类中 org.springframework.cache.annotation.CachingConfigurerSupport@Bean(destroyMethod="destroy") public org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory lettuceConnectionFactory()
Copyright © 2024. All rights reserved.