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. |
zcount key 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, -INF and + INF indicate the highest and lowest scores of sorted-sets, respectively. by default, min and Max indicate a closed range. That is, members in min <= score <= max are returned. However, we can add the " (" character before min and Max to indicate the open interval, for example, (min max indicates min , while (min (max indicates min . |
Number of Members in the score range. |
zincrby key 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. |
new score expressed as a string. |
zrange key start stop [withscores] |
O (log (n) + m) |
in time complexity, N indicates the number of members in sorted-set, 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 withscores option, the command returns a score value for each member, such as value1, score1, value2, score2 .... |
returns the list of members of the index between start and stop. |
zrangebyscore key min max [withscores] [limit offset count] |
O (log (n) + m) |
in time complexity, N indicates the number of members in sorted-set, 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 parameters 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. |
zrevrange key Start stop [withscores] |
O (log (n) + m) |
in time complexity, N indicates the number of members in sorted-set, 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. |
return the list of specified members. |
ZrevrankKey Member |
O (log (n )) |
N in time complexity indicates the number of sorted-set members. Functions andZrankBasically the same. 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. In addition to sorting by scores from high to low, this command has the same meaningsZrangebyscoreSame. |
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, referZcount. |
The number of deleted members. |