Command prototype |
Time Complexity |
Command description |
Return Value |
ZaddKey score member [score] [member] |
O (log (n )) |
N in time complexity indicates the number of sorted-sets members. Add all members specified in the parameter and their scores to the sorted-set of the specified key. In this command, we can specify multiple groups of score/member as the parameter. If a member in the parameter already exists at the time of addition, the command updates the score of the member to a new value and sorts the member based on the new value. If the key does not exist, this command creates a new sorted-sets value for the key and inserts the score/member pair into it. If the key already exists, but the value associated with it is not of the sorted-sets type, related error messages will be returned. |
The number of actually inserted members in this operation. |
ZcardKey |
O (1) |
Obtain the number of sorted-sets associated with the key. |
Returns the number of sorted-sets members. If the key does not exist, 0 is returned. |
ZcountKey min max |
O (log (n) + M) |
In time complexity, N indicates the number of members in sorted-sets, and M indicates the number of elements between min and Max. This command is used to obtain the number of members of a score between min and Max.For Min and Max parameters,-INFAnd+ INFThe highest and lowest scores in sorted-sets.By default, Min and Max indicate a closed range, that isMin <= score <= max. However, we can add"("Character to indicate the open interval, for example, min maxMin <score <= maxAnd (min (max)Min <score <Max. |
The number of members in the specified range. |
ZincrbyKey increment Member |
O (log (n )) |
N in time complexity indicates the number of sorted-sets members. This command adds the specified score to the specified Member of the specified key. If the member does not exist, this command adds the Member and assumes that its initial score is 0, and then adds the score to the increment. If the key is not saved, this command creates the key and its associated sorted-sets, and contains the members specified by the parameter. The score is the increment parameter. If the associated key is not of the sorted-sets type, the error message is returned. |
The new score in the form of a string. |
ZrangeKey start stop [withscores] |
O (log (n) + M) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of returned Members. This command returns the members in the specified range of the start and stop parameters. Here, the start and stop parameters are both 0-based, that is, 0 indicates the first member, and-1 indicates the last member. If start is greater than the maximum index value in the sorted-set, or start> stop, an empty set is returned. If the stop value is greater than the maximum index value, the command returns the last Member from start to the set.If the command contains the optional parameter withscores, the returned result contains the score values of each member, such as value1, score1, value2, score2 .... |
Returns the list of members of the index between start and stop. |
ZrangebyscoreKey min max [withscores] [limit offset count] |
O (log (n) + M) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of returned Members. This command returns all the Members whose scores are between min and Max, that is, the members that meet the expression min <= score <= max. The returned Members are returned in the order from low to high, if the members have the same scores, the results are returned in alphabetical order. The optional parameter limit is used to limit the number of returned Members. The optional parameter offset indicates that the return starts from the offset member that meets the condition and returns the Count member. For the meaning of the optional parameter withscores, refer to the description of this option in zrange.Note that the min and Max rules in the parameter can be referred to the zcount command. |
Returns the list of Members whose scores are in the specified range. |
ZrankKey Member |
O (log (n )) |
N in time complexity indicates the number of sorted-set members. Members in sorted-set are stored in the order of low to high scores. This command returns the Location Value of the specified member in the parameter, where 0 indicates the first member, it is the member with the lowest score in sorted-set. |
If this member exists, its location index value is returned. Otherwise, Nil is returned. |
ZremKey member [member...] |
O (m log (n )) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of deleted members. This command removes the specified member from the parameter, and the nonexistent member is ignored. If the value associated with the key is not sorted-set, the error message is returned. |
The actual number of deleted members. |
ZrevrangeKey startstop [withscores] |
O (log (n) + M) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of returned Members. The function of this command is basically the same as that of zrange. The only difference is that this command obtains the members at the specified position through reverse sorting, that is, the order from high to low. If the members have the same scores, they are sorted alphabetically in descending order. |
Returns the list of specified members. |
ZrevrankKey Member |
O (log (n )) |
N in time complexity indicates the number of sorted-set members. The function of this command is basically the same as that of zrank. The only difference is that the index obtained by this command is the position from high to low. Similarly, 0 indicates the first element, that is, the member with the highest score. |
If this member exists, its location index value is returned. Otherwise, Nil is returned. |
ZscoreKey Member |
O (1) |
Obtains the score of a specified member of a specified key. |
If the member exists, the score is returned as a string; otherwise, Nil is returned. |
ZrevrangebyscoreKey Max min [withscores] [limit offset count] |
O (log (n) + M) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of returned Members. This command not only sorts scores from high to low, but also has the same meanings as zrangebyscore. |
Returns the list of Members whose scores are in the specified range. |
ZremrangebyrankKey start stop |
O (log (n) + M) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of deleted members. Delete the Members whose index positions are between start and stop. Both start and stop are 0-based, that is, 0 indicates the member with the lowest score, and-1 indicates the last Member, that is, the member with the highest score. |
The number of deleted members. |
ZremrangebyscoreKey min max |
O (log (n) + M) |
In time complexity, N indicates the number of sorted-set members, and M indicates the number of deleted members. Delete all members whose scores are between min and Max, that is, all members whose expressions meet Min <= score <= max. Min and Max parameters can be expressed in the open interval mode. For specific rules, see zcount. |
The number of deleted members. |