use of org.springframework.data.redis.serializer.StringRedisSerializer in project dq-easy-cloud by dq-open-cloud.
the class EcDefaultRedisConfig method redisTemplateValueSerializer.
/**
* <p>
* 实例化 RedisTemplate 对象--保存的值为对象经过jdk序列化后的对象
* </p>
*
* @return
* @author daiqi
* @date 2017年12月7日 下午5:19:51
*/
@Bean(value = EcRedisTemplateName.REDIS_TEMPLATE_VALUE_SERIALIZER_NAME)
public RedisTemplate<String, Object> redisTemplateValueSerializer(@Qualifier(value = "defaultRedisConnectionFactory") RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.setConnectionFactory(redisConnectionFactory);
return redisTemplate;
}
Aggregations