Redis Usage Scenarios:
1. Displays the most recent list of items in the home page.
2. Delete and filter
3. Leaderboards and related issues.
4. Sort by user vote and time.
5. Expired item processing.
6. Count.
7. Specific items within a specific time period.
8. Real-time analysis of what is happening, for data statistics and prevention of spam.
9. Pub/sub.
10. Queue.
11. Cache.
12. List of followers.
13. Common concern.
...............
1. Redis contains the following structure (from the official):
Binary-safe strings.
Lists:collections of string elements sorted according to the order of insertion. They is basically linked lists.
Sets:collections of unique, unsorted string elements.
Sorted sets, similar to sets but where every string element was associated to a floating number value, called score. The elements taken sorted by their score, so unlike sets it's possible to retrieve a range of elements (for ex Ample ask:give me the top, or the bottom 10).
Hashes, which is maps composed of fields associated with values. Both the field and the value are strings. This is very similar to Ruby or Python hashes.
Bit arrays (or simply bitmaps): it is possible, using special commands, to handle String values like an array of bits:you can set and clear individual bits, count all of the bits set to 1, find the first set or unset bit, and so forth.
Hyperloglogs:this is a probabilistic data structure which are used in order to estimate the cardinality of a set. Don ' t be scared, it's simpler than it seems ... See later in the Hyperloglog sections of this tutorial.
2, String Type Summary
A), a string of type value maximum is 512M. You can store any type of data.
b), mset,msetnx difference, when using MSETNX, the statement will not execute as long as there is a key present.
c), used to count the number of users monthly login, can use Setbit,getbit,bitcount, small space and convenient.
3, List Type summary
A), String type 2 -1 , when the list data reaches millions of, access data is still very fast (slower access to the intermediate data in the list), time complexity O (N).
b), using the timeline, you can use Lpush to put the data on the top, through the lrange to get the data
c), the result of top n is reached by deleting the data that is not accessed by LTrim.
d), Blpop, Brpop, Brpoplpush gets the data, it blocks the current process until the data is fetched or at the specified time (unit s)
This article is from the "Peter's Future" blog, so be sure to keep this source http://peterxu.blog.51cto.com/1391852/1661322
A summary of Redis