Difference between RedisTemplate and StringRedisTemplate

When I used redis in the springboot project today, I encountered a problem. When I used the RedisTemplate class to store data in redis, it was obvious that the data was stored and it could be taken out, but rdm just couldn't see the value of the key. An example on the Internet As you can see, the original class serializes the value of the key by default. If you want to use the RedisTemplate class, you must specify a type for it, for example: RedisTemplate<String,String> or use the StringRedisTemplate class to save. I also learned the source code and found that this StringRedisTemplate inherits RedisTemplate, whichever one I use is similar and can meet daily needs

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324475471&siteId=291194637