Lock screen interview questions 100 days brush, every weekday insist on updating the interview questions. Lock screen interview app and mini program are now online, official website address: www.demosoftware.cc/#/introduct… . Has included the daily update of all the content of the interview questions, also includes features to unlock the screen to review the interview questions, daily programming questions email push and other functions. Let you in the interview one step ahead, blow the interviewer! Here’s today’s interview question:

==== What can be done to reduce Redis memory usage?

If you are using a 32-bit Redis instance, you can make good use of the Hash,list,sorted set,set, etc., as many small key-values can often be grouped together in a more compact way.

What happens when ====Redis runs out of memory?

If the upper limit is reached, Redis write commands will return an error message (but read commands will return normally). Or you can use the configuration flush mechanism by using Redis as a cache, flushing out old content when Redis reaches its memory limit.

==== How many keys can a Redis instance hold? List, Set, SortedSet How many elements can they hold?

In theory Redis can handle up to 2^32 keys and has been tested in practice with at least 250 million keys per instance. We are testing some larger values. Any list, set, and sorted set can have 2^32 elements. In other words, the storage limit of Redis is the amount of available memory in the system.

====MySQL has 2000W data, redis only 20W data, how to ensure that the data in Redis is hot data?

When the Redis memory data set grows to a certain size, a data obsolescence strategy is implemented. Interviewers may ask about elimination strategies later…

==== If there are 100 million keys in Redis, 10W of them start with a fixed known prefix, what if you find all of them?

Use the keys command to scan out a list of keys for a given pattern. If the redis is providing services to online businesses, what is the problem with using keys? This is the time to answer a key redis feature: Redis single threaded. The keys command causes the thread to block for a period of time and the online service to pause until the command is executed. In this case, scan command can be used. Scan command can extract the key list of the specified mode without blocking, but there will be a certain probability of repetition. It is ok to perform deduplication on the client, but the overall time will be longer than that of direct keys command.

==== If a large number of keys need to be set to expire at the same time, what should I pay attention to?

If a large number of key expiration times are set too centrally, redis may experience a temporary lag at that point in time. It is generally necessary to add a random value to the time to spread out the expiration time.

==== have you used Redis for asynchronous queues and how?

The list structure is typically used as a queue, with RPUSH producing messages and LPOP consuming messages. When there are no LPOP messages, sleep for a while and try again. What if the other person asks if it’s ok not to sleep? List also has a directive called blPOP, which blocks when there is no message until it arrives. If the other party asks can produce once consume many times? Using the PUB/SUB topic subscriber pattern, a 1:N message queue can be implemented. What are the disadvantages of pub/sub? In the event that the consumer goes offline, the production message is lost and a professional message queue such as RabbitMQ is used. If the other party asks how redis realizes the delay queue? I bet right now you’d want to beat the interviewer to death if you had a baseball bat in your hand. But you are very restrained and calmly answer: Use sortedSet, take timestamp as score, call Zadd for message content as key to produce message, and the consumer uses ZrangebyScore command to get data polling N seconds ago for processing. At this point, the interviewer has secretly given you a thumbs-up. But what he doesn’t know is that right now you’re sticking your middle finger up behind your chair.

More interview questions can be paid attention to “Demo locked screen interview questions” public account through the mini program or App to obtain interview questions and learning resources