How it works...

For Spring Data Redis, the first instance you should create is the RedisTemplate, which will be used for Redis data manipulation. Before the RedisTemplate is instantiated, a JedisConnectionFactory is needed for the settings of the host and the port of Redis. For more reliable connection management, we also enabled the connection pool of the Redis clients.

After getting the RedisTemplate instance, we set the serializer of the key, hash key, and hash value respectively. For the key and hash key of the hash data in this demo, we just use plain text. For the hash value, the JSON format is used for better data organization.

Since we have prepared the RedisTemplate instance and its related settings, we can use it to implement the ...

Get Redis 4.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.