Redis ordered Collection

Source: Internet
Author: User
Tags ranges

Redis ordered collections are similar to Redis collections stored in setpoint uniqueness. The difference is that each member of an ordered set has fractions that are used in order to take an ordered set command, from the smallest to the largest fraction.

Redis ordered set adds, deletes, and tests the presence member of O (1) (fixed time, regardless of the number of elements contained within the collection). The maximum length of the list is 232-1 elements (4294967295, more than 4 billion of each element's collection).

Example
Redis 127.0.0.1:6379> Zadd Tutorials 1 redis (integer) 1redis 127.0.0.1:6379> zadd Tutorials 2 mongodb (integer) 1redi S 127.0.0.1:6379> zadd Tutorials 3 mysql (integer) 1redis 127.0.0.1:6379> zadd Tutorials 3 mysql (integer) 0redis 127. 0.0.1:6379> Zadd Tutorials 4 mysql (integer) 0redis 127.0.0.1:6379> zrange Tutorials 0 WITHSCORES1) "Redis" 2) "1" 3 ) "MongoDB" 4) "2" 5) "MySQL" 6) "4"

In the above example, the three values are inserted by the command zadd with their fractions in the Redis sort set and named tutorials.

Redis Sort Command Set

As the following table shows with the?? Some basic commands for sorting sets:

S.N. Command & Description
1 Zadd key Score1 member1 [Score2 member2]
Add one or more members to an ordered collection, or update their scores if it already exists
2 Zcard Key
The number of ordered collection members to get
3 Zcount Key min Max
Calculates the fraction of an ordered set member with a given range of values
4 Zincrby Key Increment member
Increase a member's score in an ordered set
5 Zinterstore destination Numkeys key [key ...]
A multiple-cross-sorted collection, and stores a new ordered collection of keys.
6 Zlexcount Key min Max
Calculates the number of ordered collection members between a given dictionary range
7 Zrange key start stop [Withscores]
Returns an ordered collection of member scopes by the index.
8 Zrangebylex key min Max [LIMIT offset Count]
Returns an ordered collection of member scopes (by dictionary scope)
9 Zrangebyscore key min Max [withscores] [LIMIT]
Returns an ordered collection of member scopes by fractions.
10 Zrank Key Member
Determines an ordered collection of members in the index
11 Zrem key member [member ...]
Remove one or more members from an ordered collection
12 Zremrangebylex Key min Max
Removes an ordered collection of all members between a given dictionary range
13 Zremrangebyrank Key Start stop
Removes an ordered collection of all members within a given index
14 Zremrangebyscore Key min Max
Removes an ordered collection of all members within a given fraction
15 Zrevrange key start stop [Withscores]
Returns an ordered collection of member ranges, sorted by index, from high to low
16 Zrevrangebyscore key Max min [Withscores]
Returns an ordered collection of member ranges, sorted by fractions, by fractions, from high score to low score
17 Zrevrank Key Member
Determines the index of an ordered collection member, sorted by fractions, from high score to low score
18 Zscore Key Member
Gets the associated fraction of a given member in an ordered collection
19 Zunionstore destination Numkeys key [key ...]
To add multiple sets of sorts, the resulting sorted collection is stored in a new key
20 Zscan key cursor [MATCH pattern] [count Count]
Increments an iterative ordering element set and related fractions




Article reprinted from: Yi Hundred tutorials [http:/www.yiibai.com]

This article title: Redis ordered Collection
This address: http://www.yiibai.com/redis/redis_sorted_sets.html

Redis ordered Collection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.