how to configure different ttl for each redis cache when using @cacheable in springboot2.0

后端 未结 3 461

I am using @cacheable in springboot2.0 with redis. I have configured RedisCacheManager as follow:

@Bean
public RedisCacheManager redisCacheManager(RedisConne         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-06 06:27

    If you need configure different expire time for cache when using @cacheable , you can configure different CacheManager with different ttl,and specify cacheManager when using cache in your service.

     @Cacheable(cacheManager = "expireOneHour", value = "onehour", key = "'_onehour_'+#key", sync = true)
    

提交回复
热议问题