✔ String

This type is similar to memcache and is used as a regular key-value cache. ○ For example, the number of tweets and followers.

✔ Hash

Redis hash is a mapping of fields and values of type string. Hash is particularly useful for storing objects (because objects may contain many attributes).

Stocking List

A list list is a simple list of strings, sorted by insertion order (internally implemented as a LinkedList), with the option of inserting a LinkedList to the head or tail. Common commands are as follows: ○ Lpush /rpush: add the left and right elements ○ LPOP/RPOP: remove the first left and right elements ○ Lrange: obtain list fragments application scenarios ○ Message queue: Redis linked list structure, can easily achieve blocking queue, can use left in right out of the command to complete the design of the queue.

✔ Set

Case: In microblog, all the followers of a user can be put into a collection, and all the fans can be put into a collection. Redis also provides operations such as seeking intersection, union and difference sets for collections, which can realize functions such as common concern, common preference and second degree friends. For all of the above collection operations, you can also use different commands to choose whether to return the results to the client or to store them in a new collection.

○ Face-to-face group building

✔ ✔ SortedSet

Inside redis sorted set, HashMap and SkipList are used to ensure the storage and order of data. HashMap contains the mapping of members to score, and the skip table stores all set elements according to score from small to large. Using skip list structure can obtain relatively high search efficiency, and relatively simple to implement. The time complexity of a red-black tree is the same as that of a red-black tree.

Application scenarios: ○ Ranking: An ordered collection of classic usage scenarios. For example, a video website needs to make a list of videos uploaded by users. The maintenance of the list may be in many aspects: by time, by play quantity, by the number of likes obtained, etc. ○ Use Sortedset as a queue with weights. For example, the score of common messages is 1, and the score of important messages is 2. Then, the worker thread can choose to obtain work tasks in reverse order of score, so that important tasks are executed first. ○ Class report card

☺ HyperLogLog

• For inaccurate recasting function, more suitable for large-scale data recasting, such as statistics UV;

☺ Geospatial

• Can be used to save geographical location, and for location example calculation or according to the radius of the location calculation, etc. • People nearby • Calculate the optimal map path

☺ Pub/Sub: Topic subscription mode

A 1: N message queue can be implemented, but in the case of a consumer offline, the production message is lost and a professional message queue such as RocketMQ is used.