Redis data type of zset

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/lianghecai52171314/article/details/102715966

Redis data type of zset

zset: ordered but can not be repeated

zadd key score member [[score member] [score member] …]

The member of one or more elements and their score values ​​among the key is added to the ordered set.
Here Insert Picture Description
Here Insert Picture Description

zcard key

Return ordered set of base key.
Here Insert Picture Description

zcount key min max

Returns the ordered set key, score values ​​between min and max (including default score value equal to min or max) of the number of members.

Here Insert Picture Description

zincrby key increment member

As the score value of a member member of an ordered set of key plus the increment increment.
Here Insert Picture Description

zrange key start stop [withscores]

Return ordered set key, specify members within range.
The position where the members of the press score value is incremented (small to large) to sort.
Here Insert Picture Description

zrangebyscore key min max [withscores] [limit offset count]

Returns the ordered set key, all the score value range (including equal to min or max) between members min and max. Ordered set by a member of score value is incremented (small to large) arranged in the order.
LIMIT parameter specifies the number of results returned and intervals (as in SQL SELECT LIMIT offset, count)
Here Insert Picture Description

zrem key member [member …]

移除有序集 key 中的一个或多个成员,不存在的成员将被忽略。
当 key 存在但不是有序集类型时,返回一个错误。
Here Insert Picture Description

zremrangebyrank key start stop

移除有序集 key 中,指定排名(rank)区间内的所有成员。
区间分别以下标参数 start 和 stop 指出,包含 start 和 stop 在内。
下标参数 start 和 stop 都以 0 为底,也就是说,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。
你也可以使用负数下标,以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。
Here Insert Picture Description
Here Insert Picture Description

zremrangebyscore key min max

移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。

Here Insert Picture Description

zrevrange key start stop [withscores]

返回有序集 key 中,指定区间内的成员。
其中成员的位置按 score 值递减(从大到小)来排列。
具有相同 score 值的成员按字典序的逆序(reverse lexicographical order)排列。
Here Insert Picture Description

zrevrangebyscore key max min [withscores] [limit offset count]

返回有序集 key 中, score 值介于 max 和 min 之间(默认包括等于 max 或 min )的所有的成员。有序集成员按 score 值递减(从大到小)的次序排列。
Here Insert Picture Description

zrevrank key member

返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递减(从大到小)排序。
排名以 0 为底,也就是说, score 值最大的成员排名为 0 。

Here Insert Picture Description

zscore key member

返回有序集 key 中,成员 member 的 score 值。
如果 member 元素不是有序集 key 的成员,或 key 不存在,返回 nil 。
Here Insert Picture Description

zunionstore destination numkeys key [key …] [weights weight [weight …]] [aggregate sum|min|max]

Calculation given one or more ordered sets and sets, wherein a given number of key numkeys parameters must be specified, and the union (the result set) to the storage destination.
By default, the result set the value of a member's score is set at any given value of the score and members.
weights
before using weights option, you can specify a multiplication factor (multiplication factor) for each given separately ordered set, each given a score ordered set of values passed to all members of an aggregate function (aggregation function) should be multiplied by a factor of the first ordered set.
If the option is not specified weights, multiplication factor default setting is 1.
aggregate
aggregation mode using the aggregate option, you can specify and set the result set.
The default parameters used in sum, score values of all members of a set of the result set and may be used as the score value of the member; parameter min, a minimum score may be set for all values as a result of concentration of a member of the member score value; max sucked and all parameters set maximum score value of a member as a result of the focus score values member.

Here Insert Picture Description

zinterstore destination numkeys key [key …] [weights weight [weight …]] [aggregate sum|min|max]

Computing the intersection of a given one or more ordered sets wherein a given number of key parameters must be specified numkeys, and the intersection (result set) to the storage destination.
By default, the result set score value of a member's score is the sum of all the members of a given set and

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/lianghecai52171314/article/details/102715966