use of org.springframework.data.redis.serializer.GenericToStringSerializer in project moon by gentoo111.
the class RedisConfig method redisTemplate.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Bean("redisTemplate")
public RedisTemplate redisTemplate(@Lazy RedisConnectionFactory connectionFactory) {
RedisTemplate redis = new RedisTemplate();
GenericToStringSerializer<String> keySerializer = new GenericToStringSerializer<String>(String.class);
redis.setKeySerializer(keySerializer);
redis.setHashKeySerializer(keySerializer);
GenericJackson2JsonRedisSerializer valueSerializer = new GenericJackson2JsonRedisSerializer();
redis.setValueSerializer(valueSerializer);
redis.setHashValueSerializer(valueSerializer);
redis.setConnectionFactory(connectionFactory);
return redis;
}
Aggregations