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