Spring Data Cache, Redis configuration serialization to JSON

There are many programs for Java to operate Redis. Commonly used Redis Java clients are: Jedis (a more popular program at present), Lettuce, Redison, Spring Data Redis.

Spring-data-redis is a sub-project of the Spring-Data project. The Spring framework is a sub-framework that integrates Redis operations. It encapsulates many Redis commands. It is easy to use Spring to operate Redis databases. Through the Spring-data-redis tool, Make the operation of Redis in a more object-oriented way.

Spring-data-redis is a part of spring. It provides access to redis services through simple configuration in the srping application, and highly encapsulates the underlying reids development kits (Jedis, JRedis, and RJC). RedisTemplate provides various redis operations, Exception handling and serialization, support for publish and subscribe, and implement spring 3.1 cache. SpringCache is not a kind of Cache implementation technology. SpringCache is a general-purpose technology for cache implementation. Based on the Cache framework provided by Spring, it is easier for developers to embed their own cache implementation into their projects efficiently and conveniently. Of course, SpringCache also provides its own simple implementation of NoOpCacheManager, ConcurrentMapCacheManager, etc. 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 the 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, 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