redis What are the data types ? Which scenarios are suitable for use ?
Psychological analysis of interviewers
Analysis of interview questions
redis There are mainly the following data types ：
This is the simplest type , It's ordinary set and get, Do simple KV cache .
This is similar map A structure of , This is generally structured data , Like an object （ The premise is that the object is not nested with other objects ） To cache in redis
in , And then every time I read and write the cache , It can be operated on hash A field in the .
list There is a sequence table , This one can play a lot of tricks .
For example, you can pass the list Store some tabular data structures , Similar to fan list , A list of comments on an article or something .
For example, you can pass the lrange command , Read the elements in a closed interval , Can be based on list Realize paging query , This is a great feature , be based on redis
Implementation of simple high performance paging , You can do things like microblogging that pull down and page constantly , High performance , Just go page by page .
For example, we can build a simple message queue , from list Head in , from list Get it out of the tail .
set It's an unordered set , Automatic weight removal .
Two big V The fans are all in two set in , Yes, two set Do intersection .
sorted set It's sorted set, De duplication but can be sorted , Give a score when you write it in , Automatically sort by score .