Function Introduction
Most of the users like to use Redistemplate, and its corresponding package is org.springframework.data.redis.core. The template is actually the core class of the Redis module because of its rich functionality. Templates provide a high level of abstraction for redis interactions. Although Redisconnection provides a low-level way to accept and return binary values (byte arrays), the template can handle serialization and connection management so that users do not have to deal with too much detail.
In addition, templates provide operation views (grouped by Redis Command Reference), which provide a rich, out-of-the-box interface for operations on specific types or specific keys (via the Keybound interface), as described below:
Interface |
Description |
Key type operation |
Valueoperations |
Manipulating Redis String (or value) type data |
Listoperations |
Manipulating Redis list type data |
Setoperations |
Manipulating Redis set type data |
Zsetoperations |
Manipulating Redis Zset (or sorted Set) type data |
Hashoperations |
Manipulating Redis Hash type data |
Hyperloglogoperations |
Operation of Redis Hyperloglog type data, such as: Pfadd,pfcount, ... |
Geooperations |
Operation of Redis geospatial type data such as: Geoadd,georadius,...) |
Key binding operation |
Boundvalueoperations |
Redis string (or value) key binding operation |
Boundlistoperations |
Redis List Key binding operations |
Boundsetoperations |
Redis Set Key binding operation |
Boundzsetoperations |
Redis Zset (or sorted Set) key binding operation |
Boundhashoperations |
Redis Hash Key binding operation |
Boundgeooperations |
Redis Geospatial Key Binding operation |
Once configured, the template is thread-safe and can be reused by multiple instances.
Out of the box, Redistemplate uses a Java-based serializer to do most of the work. This means that any object that reads and writes through the template will be serialized/deserialized through Java. The serialization mechanism of the template is also easy to change, and the Redis module provides a variety of implementations available in the Org.springframework.data.redis.serializer package, see serializers for details. You can also set the Enabledefaultserializer property to false by setting the other serialization implementation to NULL, and use the redistemplate with the native byte array. Note that the template's key is not allowed as a null value unless the underlying serializer can accept it. For more information on serializers, please read Javadoc.
===================================================================