package cn.wise.sc.energy.power.plant.business.config;

import org.redisson.api.RedissonClient;
import org.redisson.spring.cache.CacheConfig;
import org.redisson.spring.cache.RedissonSpringCacheManager;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Configuration
@EnableCaching
public class CacheManagerConfig {

    @Resource
    RedissonClient redissonClient;

    @Bean
    CacheManager cacheManager() {
        Map<String, CacheConfig> config = new HashMap<>();
        config.put("SYSTEM_PARAM", new CacheConfig(0, 15 * 60 * 1000));
        return new RedissonSpringCacheManager(redissonClient, config);
    }
}