In what form does Redis store data? What is a hash slot?

It’s a String, a List, a Hash, a Set, a Sorted Set.

The Redis cluster has 16384 built-in hash slots. When a key-value needs to be placed in the Redis cluster, The Redis first uses crC16 algorithm to calculate a result for the key, and then calculates the remainder of the result for 16384. In this way, each key will correspond to a hash slot numbered between 0 and 16383, and Redis will map hash slots to different nodes roughly equally based on the number of nodes. Instead of using consistent hash, the Redis cluster introduces the concept of a hash slot. Each key is verified by CRC16 and the module of 16384 is taken to determine which slot to place. Each node in the cluster is responsible for a portion of the hash slot. This structure makes it easy to add or remove nodes without making the cluster unavailable by adding or deleting or modifying a node. When you need to add nodes, you just need to move some hash slots of other nodes to the new node. When you need to remove a node, you only need to move the hash slot on the removed node to another node.

Use RedisTemplate for caching

    @Autowired

private RedisTemplate redisTemplate;

Add to the cache, TbItemCatOneExample: the name given, 0 to find the data identified by 0 in TbItemCatOneExample

List

selectAll = itemcatmapper.selectAll ();

redisTemplate.boundHashOps(“TbItemCatOneExample”).put(0, selectAll);

redisTemplate.boundHashOps(“TbItemCatOneExample”).delete(0);

redisTemplate.boundHashOps(“TbItemCatOneExample”).get(0);