Yo,
I was using a redis client in node js with Redis insight and everything was smooth. Now I'm trying a Spring App with Jedis however every key I insert is surrounded by doublequotes which makes the Tree view feature of Redis insight to not work.
Here is my template config:
@Bean
public RedisTemplate<String, Object> redisTemplate(@Nonnull RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
template.setDefaultSerializer(new GenericJackson2JsonRedisSerializer());
return template;
}
I thought maybe something was wrong with the serializer, so I even tried something like this
template.setStringSerializer(new GenericToStringSerializer<>(String.class));
However this doesn't seem a serializer issue since I checked the bytes and everything looks fine.
Searched Redis Insight settings for a little bit and couldn't find anything, any ideas?
The reason is that your key serialized into json instead of plain text. Use string serializer for keys.
Add this line to your template bean creation method
template.setKeySerializer(new StringRedisSerializer());