I. BackgroundThe recent use of Spring-data-redis and Jedis to operate Redis found that the key stored in Redis is not a string value set in the program, and there are many more strings similar to \xac\xed\x00\x05t\x00 in front of it.
Second, the reasonSpring-data-redis redistemplate<k, v> template classes use Jdkserializationredisserializer to serialize when working with Redis
Jdkserializationredisserializer (); null ; valueserializernull; null; null;
Third, the solutionReplace the Keyserializer,hashkeyserializer with the StringredisserializerIt can be injected in a way that:
<beanID= "Redistemplate"class= "Org.springframework.data.redis.core.RedisTemplate"><propertyname= "ConnectionFactory"ref= "Jedisconnectionfactory"/><propertyname= "Keyserializer"><beanclass= "Org.springframework.data.redis.serializer.StringRedisSerializer"/></property><propertyname="Hashkeyserializer"><beanclass= "Org.springframework.data.redis.serializer.StringRedisSerializer"/></property></bean>
Spring-data-redis Workarounds for key values and presets when storing using redistemplate templates