Class RedisCacheConfig

java.lang.Object
com.bytedesk.core.redis.cache.RedisCacheConfig
All Implemented Interfaces:
org.springframework.cache.annotation.CachingConfigurer

@Configuration @EnableCaching @Role(2) public class RedisCacheConfig extends Object implements org.springframework.cache.annotation.CachingConfigurer
cache config https://docs.spring.io/spring-boot/reference/io/caching.html https://docs.spring.io/spring-data/redis/reference/redis/redis-cache.html https://docs.spring.io/spring-framework/reference/integration/cache/annotations.html#cache-spel-context https://docs.spring.io/spring-boot/docs/3.2.0/reference/htmlsingle/#io.caching https://www.51cto.com/article/753777.html
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
     
    private com.fasterxml.jackson.databind.ObjectMapper
     
    private long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private org.springframework.data.redis.cache.RedisCacheConfiguration
    默认缓存配置 使用Jackson作为JSON序列化器,需要包含类型信息以便正确反序列化
    org.springframework.cache.interceptor.CacheErrorHandler
     
    org.springframework.data.redis.cache.RedisCacheManager
    redisCacheManager(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
    Redis缓存管理器配置 支持TTL和自定义序列化

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.cache.annotation.CachingConfigurer

    cacheManager, cacheResolver, keyGenerator
  • Field Details

    • timeToLive

      @Value("${spring.cache.redis.time-to-live:1800000}") private long timeToLive
    • keyPrefix

      @Value("${spring.cache.redis.key-prefix:bytedeskim:cache:}") private String keyPrefix
    • objectMapperBean

      @Autowired @Qualifier("redisObjectMapper") private com.fasterxml.jackson.databind.ObjectMapper objectMapperBean
  • Constructor Details

    • RedisCacheConfig

      public RedisCacheConfig()
  • Method Details

    • redisCacheManager

      @Bean @ConditionalOnProperty(name="spring.cache.type", havingValue="redis", matchIfMissing=false) public org.springframework.data.redis.cache.RedisCacheManager redisCacheManager(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
      Redis缓存管理器配置 支持TTL和自定义序列化
    • defaultCacheConfiguration

      private org.springframework.data.redis.cache.RedisCacheConfiguration defaultCacheConfiguration()
      默认缓存配置 使用Jackson作为JSON序列化器,需要包含类型信息以便正确反序列化
    • errorHandler

      public org.springframework.cache.interceptor.CacheErrorHandler errorHandler()
      Specified by:
      errorHandler in interface org.springframework.cache.annotation.CachingConfigurer