redis command of ---- SortedSed (ordered set)

ZADD

ZADD key score member [[score member] [score member] ...]

One or more  member  elements and their  score  value is added to the ordered set  key  among.

If a  member  is already a member of an ordered set, then update the  member  's  score  value, and by re-insertion of this  member  elements to ensure that the  member  in the correct position.

score  value may be an integer or a double precision floating point value.

If the  key  does not exist, create an empty set and ordered to perform  ZADD  operation.

When the  key  but when there is not an ordered set type, returns an error.

More on ordered sets, refer  sorted the SET  .

 

ZCARD

SCARD key

Returns a collection of  key  cardinality (number of elements in the set).

 

ZCOUNT

ZCOUNT key min max

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

About the parameters  min  and  max  detailed methods of use, please refer to  ZRANGEBYSCORE  command.

 

ZINCRBY

Is an ordered set of  key  members of the  member  's  score  value plus incremental  INCREMENT  .

It can be a negative value by passing  INCREMENT  , so that  score  by subtracting the corresponding values, such as  ZINCRBY  Key  -5  member  , is to make the  member  of the  score  value minus  5  .

When the  key  is not present, or the  member  is not a  key  when a member,  ZINCRBY  key  INCREMENT  member  equivalent to  Zadd  key  INCREMENT  member  .

When the  key  when not ordered set type, returns an error.

score  value may be an integer or a double precision floating point value.

 

ZRANGE

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.

Have the same  score  members lexicographical ordering value ( the lexicographical Order  ) are arranged.

If you want members of the press  score  value decrement (descending) to arrange, use  ZREVRANGE  command.

Indexed parameters  start  and  stop  both to  0  as a substrate, i.e., to  0  the first member of an ordered set to  1  indicates the second ordered set members, and so on.
You can also use a negative index to  -1  is the last member of  -2  represents the penultimate members, and so on.
Subscript out of range does not cause an error.
For example, when the  start  value than the ordered set of maximum index bigger or  start  STOP  when,  Z Range The  command simply returns an empty list.
On the other hand, if the  stop  value of the parameter is larger than the maximum index ordered set, then Redis will  stop  as the largest index to deal with.
By using  WITHSCORES  option to allow members and its  score  value returned together to return the list to  value1, score1,  ...,  valueN, scoreN  the format.
The client library may return some of the more complex data types, such as arrays, tuples and so on.

 

ZRANGEBYSCORE

ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

Returns the ordered set  key  , all  score  values between  min  and  max  (including equal between the  min  or  max  ) members. Ordered set by a member of  score  value is incremented (small to large) arranged in the order.

It has the same  score  members lexicographical ordering value ( the lexicographical Order ) are arranged (the property is provided by an ordered set, no additional calculations).

The optional  LIMIT  parameter specifies the number of results returned and intervals (like SQL in  the SELECT  LIMIT  offset,  COUNT  ), pay attention to when  offset  is large, positioning  offset  operations may need to traverse the entire ordered set, the complexity of this process is the worst It is O (N) time.

The optional  WITHSCORES  parameter determines the result set is the only member of an ordered set of return, or the ordered set of members and their  score  values returned together.

 

Zrankou

ZRANK key member

Returns an ordered set of  key  members  member  rankings. Wherein the ordered set by a member of  score  value is incremented (ascending) order.

Ranking to  0  as the bottom, that is to say,  Score  smallest member of the value of the ranking is  0  .

Use  ZREVRANK  command to get members of the press  score  value decrement (descending) arranged in the rankings.

 

Zrem

ZREM key member [member ...]

Removal of an ordered set of  key  one or more members, there is no member will be ignored.

When the  key  but when there is not an ordered set type, returns an error.

 

ZREMRANGEBYRANK

ZREMRANGEBYRANK key start stop

Remove the ordered set  key  , all the members in the interval specified rank (rank).

The following intervals were marked parameters  start  and  stop  points out, contain  start  and  stop  account.

Indexed parameters  start  and  stop  both to  0  as a substrate, i.e., to  0  the first member of an ordered set to  1  indicates the second ordered set members, and so on.
You can also use a negative index to  -1  is the last member of  -2  represents the penultimate members, and so on.

 

ZREMRANGEBYSCORE

ZREMRANGEBYSCORE key min max

Removing ordered set  key  , all  score  values between  min  and  max  (including equal between the  min  or  max  ) members.

 

ZREVRANGE

ZREVRANGE key start stop [WITHSCORES]

Return ordered set  key  , specify members within range.

Wherein the position of a member by  score  values of decrement (descending) are arranged.
It has the same  score  members value by reverse lexicographic order ( Reverse Order the lexicographical order).

In addition to members of the press  score  arranged for this point in descending order of value,  ZREVRANGE  other aspects and commands  ZRANGE  command.

Available versions:

 

ZREVRANGEBYSCORE

ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]

Returns the ordered set  key  in,  Score  value between  max  and  min  between (including default equal to  max  or  min  ) of all members. Ordered set by a member of  score  values of decrement (descending) order of the arrangement.

It has the same  score  members value by reverse lexicographic order ( Reverse Order the lexicographical  order).

In addition to members of the press  score  arranged for this point in descending order of value,  ZREVRANGEBYSCORE  other aspects and commands  ZRANGEBYSCORE  command.

 

ZREVRANK

ZREVRANK key member

Returns an ordered set of  key  members  member  rankings. Which ordered set by a member of  score  value decrement (descending) order.

Ranking to  0  as the bottom, that is to say,  Score  maximum value of the members ranked  0  .

Use  ZRANK  command to get members of the press  score  value is incremented (small to large) arranged in the rankings.

 

ZSCORE

ZSCORE key member

Return ordered set  key  , a member of the  member  's  score  value.

If the  member  element is not an ordered set of  key  members, or  key  does not exist, it returns  nil  .

 

ZUNIONSTORE

ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]

Calculation given one or more ordered sets and sets, in which a given  key  number must  numkeys  specified parameters, and the union (the result set) stored  Where do you want  .

By default, a member of the result set  score  values are all members of a given set this  score  value and.

WEIGHTS

Use  WEIGHTS  option, you can specify a multiplication factor (multiplication factor) were each given an ordered set of all members of each given an ordered set  score  before the value is passed to an aggregate function (aggregation function) must first multiplied by the factor of the ordered set.

If no  WEIGHTS  option, the multiplication factor default setting is  1  .

AGGREGATE

Use  AGGREGATE  option, you can specify a set of aggregation and the result set.

Using the default parameters of  the SUM  , may be a member of all sets  score  value and the result set as the member  score  values; parameters  MIN  , the minimum can be a member of all sets  score  as the result of the focus member  score  values; and parameter  MAX  all collections sucked a member of the largest  score  value as a member of the result set  score  values.

 

ZINTERSTORE

ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]

Computing the intersection of a given one or more ordered sets wherein the given  key  number must  numkeys  specified parameters, and the intersection (result set) stored  Where do you want  .

By default, a member of the result set  score  values are all members of a given set this  score  value and.

About  WEIGHTS  and  AGGREGATE  description of the options, see  ZUNIONSTORE  command.

 

ZSCAN

Guess you like

Origin www.cnblogs.com/wuwuyong/p/11706432.html