A summary of Redis

Source: Internet
Author: User

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

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.