The difference and use of Jedis, RedisTemplate, StringRedisTemplate

1. The difference between Jedis and RedisTemplate

Jedis integrates the related command operations of Redis, it is the bridge of Java language to operate Redis database. The Jedis client encapsulates a large number of commands of the Redis database, so it has many Redis operation APIs. You can read  "Jedis API Documentation" .

Jedis is a Java-oriented Redis client officially recommended by Redis, and RedisTemplate is a highly encapsulated JedisApi in SpringDataRedis.

Compared with Jedis, SpringDataRedis can easily replace the Java client of Redis. Compared with Jedis, it has more features of automatic connection pool management, which is convenient for use with other Spring frameworks such as SpringCache.

2. The difference between RedisTemplate and StringRedisTemplate

StringRedisTemplate inherits from RedisTemplate, and the data of the two are not connected.

  • StringRedisTemplate can only manage the data in StringRedisTemplate.
  • RedisTemplate can only manage the data in RedisTemplate.

StringRedisTemplate adopts the serialization strategy of string by default, and RedisTemplate adopts the serialization strategy of JDK by default.

3. Use of Jedis and RedisTemplate

Please browse the following articles for how to use it:

"Java uses Jedis to operate the 5 data types of Redis"

"SpringBoot uses RedisTemplate to operate the 5 data types of Redis"

4. Performance comparison of Jedis and RedisTemplate

Conclusion: Native Jedis is more efficient than RedisTemplate.

For performance comparison, please browse the following articles:

"Comparison of the efficiency of RedisTemplate and JedisPool"

"What is the difference between Jedis and RedisTemplate"

Guess you like

Origin blog.csdn.net/pan_junbiao/article/details/108871103