All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.minlia.cloud.autoconfiguration.RedisAutoConfiguuration Maven / Gradle / Ivy

//package com.minlia.cloud.autoconfiguration;
//
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.data.redis.cache.RedisCacheManager;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
//import org.springframework.data.redis.serializer.GenericToStringSerializer;
//
//@Configuration
//public class RedisAutoConfiguuration {
//
//    private final RedisTemplate redisTemplate = new RedisTemplate();
//
//    @Bean
//    @ConditionalOnMissingBean
//    public RedisTemplate sessionRedisTemplate(RedisConnectionFactory connectionFactory) {
//        final GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
//        final GenericToStringSerializer genericToStringSerializer = new GenericToStringSerializer(Object.class);
//        redisTemplate.setConnectionFactory(connectionFactory);
//        redisTemplate.setKeySerializer(genericToStringSerializer);
//        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
//        redisTemplate.setDefaultSerializer(jackson2JsonRedisSerializer);
//        redisTemplate.setHashKeySerializer(genericToStringSerializer);
//        redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
//        return redisTemplate;
//    }
//
//    @Bean(name = "redisCacheManager")
//    @Primary
//    @ConditionalOnMissingBean
//    public RedisCacheManager redisCacheManager(RedisTemplate redisTemplate) {
//        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
//        // cacheManager.setDefaultExpiration(300);
//        return cacheManager;
//    }
//}