Redis Command Reference

Source: Internet
Author: User

Recently planning to use the Redis sorting function, so there is contact, found excellent, more than memcache feature rich. Introduce a part first, learn slowly later, slowly add.

To clarify one point, in Redis,key denotes the name of an ordered set, which is actually a member-value pair.

One, Sorted set (ordered set)

Oneself crooked, orderly set bottom should be insert sort algorithm

Zadd: The value of one or more member is score and stored in an ordered set. Increase, change

  Zadd Key score member  [score member]
Example: 'mysortedset' jim_id ' // Mysortedset is the name of the ordered collection, because many collections can be built. 90 for the score is value,jim_id is key. Attention, order .

Zrem: Remove a key-value to Delete

Zrem Key member Example:    Zrem mysortedset jim_id  // Delete jim_id This key-value pair. 

Zscore: Get value values check

Zscore Key member Example:    Zscore mysortedset jim_id  // Gets the value of jim_id in the Mysortedset collection

Zrank: Returns the rank of Menber, sorted by score value from small to large, No. 0 bit score value is minimal. If you want to score from the big to the small row, use Zrevrank.

Zrank Key member Example:     // get ranking of score values for jim_id

Zcard: Returns the cardinality of an ordered set key

Zcard Key Example:     // Mysortedset is an ordered collection name, returning the number of key-value pairs, similar to MySQL's count (*)

Zcount: Returns the number of intervals

zcount Key min Max example:      -  -  // returns the number of value values before 50~100 in the Mysortedset collection

Zincrby: Add or Subtract value

Zincrby Key Increment member Example:     -5 jim_id  // give jim_id this value, minus 5

Redis Command Reference

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.