package com.elab.redis.redisson;

import org.redisson.api.RedissonClient;
import org.redisson.client.codec.Codec;
import org.redisson.spring.cache.CacheConfig;
import org.redisson.spring.cache.RedissonSpringCacheManager;

import java.util.Map;

/**
 * 默认的缓存cache
 *
 * @author ： liukx
 * @time ： 2020/7/23 - 15:49
 */
public class DefaultRedissonSpringCacheManager extends RedissonSpringCacheManager {

    /**
     * 缓存配置
     */
    private CacheConfig cacheConfig;

    public DefaultRedissonSpringCacheManager(RedissonClient redisson) {
        super(redisson);
    }

    public DefaultRedissonSpringCacheManager(RedissonClient redisson, Map<String, ? extends CacheConfig> config) {
        super(redisson, config);
    }

    public DefaultRedissonSpringCacheManager(RedissonClient redisson, Map<String, ? extends CacheConfig> config, Codec codec) {
        super(redisson, config, codec);
    }

    public DefaultRedissonSpringCacheManager(RedissonClient redisson, String configLocation) {
        super(redisson, configLocation);
    }

    public DefaultRedissonSpringCacheManager(RedissonClient redisson, String configLocation, Codec codec) {
        super(redisson, configLocation, codec);
    }

    public CacheConfig getCacheConfig() {
        return cacheConfig;
    }

    public void setCacheConfig(CacheConfig cacheConfig) {
        this.cacheConfig = cacheConfig;
    }

    @Override
    protected CacheConfig createDefaultConfig() {
        return getCacheConfig() == null ? super.createDefaultConfig() : getCacheConfig();
    }
}
