package com.pannk.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * Redis配置
 *
 * @author wolf
 * @date 20-11-13
 */
@Configuration
public class RedisConfig {

    @Bean
    public RedisTemplate getRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate redisTemplate = new RedisTemplate();
        //设置连接工厂
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        //设置键序列化
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        //设置值序列化
        redisTemplate.setValueSerializer(new StringRedisSerializer());
        return redisTemplate;
    }
}
