派生自 projectDept/qhighschool

EricsHu
2023-08-04 6f6900cfbb38dbe967c71b4cdc886f5896d7269f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.qxueyou.scc.config;
 
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.core.RedisTemplate;
 
@Configuration
public class RedisCacheConfig extends CachingConfigurerSupport {
 
    @Value("#{${spring.redis.default.ttl}}")
    private int DEFAULT_TTL;
 
 
    @SuppressWarnings("rawtypes")
    @Bean
    public CacheManager cacheManager(RedisTemplate redisTemplate) {
        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
        cacheManager.setDefaultExpiration(DEFAULT_TTL);
        return cacheManager;
    }
}