com.soento.redis.config.RedisConfig Maven / Gradle / Ivy
package com.soento.redis.config;
import com.soento.core.consts.Constants;
import com.soento.redis.support.GenericCacheErrorHandler;
import com.soento.redis.support.GenericKeyGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
/**
* @author soento
*/
@Slf4j
@Configuration
@EnableCaching
@EnableConfigurationProperties(DefaultRedisConfig.class)
@EnableAutoConfiguration(exclude = {RedisAutoConfiguration.class})
public class RedisConfig extends CachingConfigurerSupport {
@Autowired
private DefaultRedisConfig defaultRedisConfig;
@Primary
@Bean
public RedisConnectionFactory connectionFactory() {
return defaultRedisConfig.getRedisConnectionFactory(Constants.DEFAULT_REDIS_ALIAS);
}
@Primary
@Bean
public RedisTemplate