In general, Redis's Zset provides a wealth of functionality that can form many applications.
In Redis, there are many features that are available.
Ordered set (Sorted set) zadd zrem zcard zcount zscore zincrby zrange zrevrange zrangebyscore zrevrangebyscore ZRANK ZREVRANK ZREMR Angebyrank Zremrangebyscore Zinterstore Zunionstore
However, there is currently no function to judge whether a key in the Zset has a specified member, and this is what is currently seen on the Web to write the corresponding code. And this work has found a clever and alternative approach. That is, the Zrank method is used to determine whether there is. The function interface is defined as follows:
Zrank Key Member
Returns the rank of the member member in the ordered set key. Where ordered set members are arranged in ascending order of score values (from small to large).
The ranking is based on 0, meaning that the member with the lowest score value is ranked at 0.
Use the Zrevrank command to get the ranking of members in descending order of score values (from large to small).
It can be considered that when this ranking does not exist, the member does not exist. The test is as follows:
Using the program to design, the results are as follows: