Redis ordered collection operation command

Ordered set (zset) that can be sorted SET, from small to large to be sorted, can not be duplicated elements zset element by score value is associated with each element, but it may be repeated score

Set / modify command

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 score value may be an integer or a double precision floating point value 
    member if a member of an ordered set already, the updated value of the score of the member 
    if the key does not exist, create an empty set and ordered to perform zadd operation 
    returns the new members were successfully added the number does not include those who have been updated, existing members

zincrby key increment member

    Plus the delta increment (can be negative), score value of key members of the member 
    to create an ordered set when empty key does not exist and performs zincrby operation 
    when member member does not exist, creating the member and its score is set to 0 and zincrby perform operations 
    return member new members score value (a string)

Remove command

zrem key member [member ...]: Removes the key in one or more members, there is no member will be ignored. Returns the number of members was successfully removed (not including members ignored)

zremrangebyrank key start stop: remove all members within the specified key index section (including the start and stop) of. Returns the number of members removed

zremrangebyscore key min max:

    Removing the key score value between min and max (and including mi max) members 
    may increase "(" brackets to the front to make the parameters min and max results do not include 
    the number of return members removed

Get Command

zrange key start stop [withscores]

    Returns the specified key index (may be negative) and press members in the section value score increment (ascending) to the ordered list 
    members having the same score value lexicographical ordering (lexicographical order) are arranged to 
    start is greater than the maximum index or start> stop, return empty list 
    stop is greater than the maximum index will stop as the largest index to handle 
    withscores options for members and its score value returned together to return the list to value1, score1, ..., valueN, scoreN format show

Member list within a specified key after returning in reverse order (in descending score value) subscript (may be negative) range: zrevrange key start stop [withscores]

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

    Key returns the score value between min and max (including min and max), a member of 
    min and max may be -INF (infinite) and + inf (infinitesimal), so that the case can not know the minimum and maximum score under such an order using zrangebyscore 
    optional limit parameter specifies the number of results returned and range 
    withscores option allows members together with its score value returned 
    by default, including a score value equal to the min and max members can give parameters min and max before "(" brackets so that the results do not contain, such as: 
    zrangebyscore zset (. 1 5: returns all 1 <score <= 5 members of 
    zrangebyscore zset (5 (10: returns all members 5 <score <10 is 
    returned within a specified interval list of members of the ordered set

zrevrangebyscore key min max [withscores] [limit offset count]: Returns the key in the score is between min and max members (including the min and max) and the reverse order of these members (in descending score value)

zscore key member: score value for key members return member (as a string), if the key element is not a member or members of the key does not exist returns nil

Intersection and set

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

    Calculation given one or more ordered sets and set (union) and the union (the result set) stored Where do you want 
    numkeys key for a given number of 
    weights for each option to specify a key corresponding multiplication factor , all members of the score value corresponding to the key passed to the aggregate function (Aggregate) to be multiplied by the factor before, by default. 1 
    aggregat option specification is set (union) of the result set aggregation score value 
        default sum, the sum of the score value set as a result of all the members of the same focus score value of the member; 
        min to all sets a minimum score value the same as the members of the result set as the score value of the member; 
        max all set a member of the same value as the maximum score in the result set score values of the member 
    returns the result set saved to the destination base.

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

    Calculating a given intersection or a plurality of ordered sets and the intersection (result set) to the destination store 
    the same parameters and usage zunionstore

Other commands

zcard key: Returns the key base, the key does not exist returns 0

zcount key min max: Returns the number of key members of the score value between min and max (including min and max),

zrank key member: return key members member rankings (from zero) if the member is not a key member of returns nil

zrevrank key member: return member decommitment key members (by score descending value) after ranking (starting from 0)

Guess you like

Origin www.cnblogs.com/john-xiong/p/12159095.html