Jedis is one of the popular Redis Java client, configure the JedisConnectionFactory which will create Jedis instances for connecting to the Redis server.
Create a RedisTemplate instance which helps to serialize/deserialize between the object and binary data on the Redis store.
Here StringRedisSerializer is used for serializing the key and GenericJackson2JsonRedisSerializer for the value. This template is a generified one, it can be wired to multiple components and reused as it’s thread-safe.
The cache abstraction does not provide an actual store and relies on abstraction materialized by the org.springframework.cache.Cache and org.springframework.cache.CacheManager interfaces.
RedisCacheManager is the implimentation of the CacheManager for Redis.
4. Annotating the methods
For caching declaration, the abstraction provides a set of Java annotations:
Triggers cache population
Updates the cache without interfering with the method execution
Triggers cache eviction
Redis is not a simple key-value store, it can be called as a data structure store as it’s can store data in advanced data structures. Spring Cache abstraction is a high level abstraction for interacting with the store.