There are many solutions for Java to operate Redis. Commonly used Redis Java clients include: Jedis (which is currently a more popular solution), Lettuce, Redison, and Spring Data Redis.
Spring-data-redis is a sub-project of the Spring-Data project. The Spring framework integrates a sub-framework of Redis operations. It encapsulates many commands of Redis. It is very convenient to use Spring to operate the Redis database. Through the Spring-data-redis tool, Make operating Redis in a more object-oriented way.
Spring-data-redis is a part of spring, which provides access to redis services through simple configuration in srping applications, and highly encapsulates the underlying development kits of reids (Jedis, JRedis, and RJC). RedisTemplate provides various operations of redis, Exception handling and serialization, support publish and subscribe, and implement spring 3.1 cache. SpringCache is not a certain Cache implementation technology. SpringCache is a general cache implementation technology. Based on the Cache framework provided by Spring, it makes it easier for developers to embed their own cache implementations into their own projects efficiently and conveniently. Of course, SpringCache also provides its own simple implementation NoOpCacheManager, ConcurrentMapCacheManager and so on. Through SpringCache, you can quickly embed your own Cache implementation.
In Spring Boot, the default integrated Redis is Spring Data Redis, and the default underlying connection pool uses lettuce.
rely
configuration file
Configure cache type, HOST, user name and other attributes
configuration class
Configure the serialization of RedisTemplate and the serialization of Spring Data Cache
test
Execute the code, and you can see that the data in redis has been serialized into JSON format.
Source address:
https://github.com/DDDInJava/portal/tree/Spring_Data_Cache_Redis