Lock screen interview questions 100 days brush, every weekday insist on updating the interview questions. The lock screen interview app and mini program have been launched, including all the contents of the interview questions updated every day, including the features of unlocking 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:

====Redis Pipeline has what advantage, why to use Pipeline?

Multiple IO round trips can be reduced to one, provided that there is no causal correlation between the instructions executed by the pipeline. When using Redis-Benchmark for pressure measurement, it can be found that an important factor affecting the PEAK QPS of Redis is the number of pipeline batch instructions.

==== have you used Redis clustering and how does clustering work?

  1. Redis Sentinal focuses on high availability and will automatically upgrade slave to Master if master goes down.
  2. Redis Cluster focuses on scalability. When a single Redis memory is insufficient, Cluster is used to fragment storage.

====Redis Cluster solution When can the entire cluster become unavailable?

In A cluster with three nodes A, B, and C, if node B fails without the replication model, the whole cluster will be unavailable as it lacks slots in the range 5501-11000.

What Java clients are supported by ====Redis? Which is the official recommendation?

Redisson, Jedis, lettuce, etc. Redisson is officially recommended.

What are the pros and cons of ====Jedis versus Redisson?

Jedis is the client of Java implementation of Redis. Its API provides comprehensive support for Redis commands. Redisson implements distributed and extensible Java data structures. Compared with Jedis, Redisson has relatively simple functions. It does not support string manipulation, sorting, transaction, pipeline, partitioning and other Redis features. The goal of Redisson is to promote a separation of focus from Redisso that users can focus more on processing business logic.

====Redis how to set and verify a password?

Set password: config set requirepass 123456 Authorization password: auth 123456

==== what about Redis hash slots?

The Redis cluster does not use consistent hash, but introduces the hash slot concept. The Redis cluster has 2 ^ 14 hash slots (16384), and each key is verified by CRC16 to determine which slot to place. Each node of the cluster is responsible for some hash slots.

====Redis uses the hash slot concept instead of a consistent hash algorithm. Why?

Redis Cluster is a simple hash algorithm of CRC16 created by itself. It does not use consistent hash. Redis’ crC16 (Key) Mod 16384 does a good job. It’s not as flexible as consistent hash, but it’s easy to implement and easy to add and remove nodes.

What is the master-slave replication model for ====Redis clusters?

In order to make the cluster usable even if some nodes fail or most nodes fail to communicate, the cluster uses a master-slave replication model, with n-1 replicas per node.

====Redis is there a write loss in the cluster? Why is that?

Redis does not guarantee strong data consistency, which means that in practice the cluster may lose writes under certain conditions.

==== How are Redis clusters replicated?

Asynchronous replication

==== What is the maximum number of nodes in a Redis cluster?

Two to the fourteenth, 16384.

====Redis cluster how to select a database?

The Redis cluster cannot make database selection at present, default is 0 database.

==== what about transactions in Redis?

Redis transactions can execute multiple commands at once with three important guarantees:

1) Batch operations are placed in the queue cache before sending EXEC commands.

2) After receiving the EXEC command, the transaction is executed. Any command in the transaction fails to be executed, and other commands are still executed.

3) During transaction execution, command requests submitted by other clients will not be inserted into the command sequence of transaction execution.

2. A transaction goes through the following three phases from inception to execution:

Start transaction.

Order in.

Execute transactions.

3. Related instructions in Redis include:

DISCARD

Cancels the transaction, abandoning all commands in the transaction block.

EXEC

Execute all commands within the transaction block.

MULTI

Marks the start of a transaction block.

UNWATCH

Unmonitor all keys with the WATCH command.

WATCH key [key …]

Monitor a key (or keys) and interrupt the transaction if the key (or keys) is changed by another command before the transaction executes.

4. The execution of individual Redis commands is atomic, but Redis does not add any mechanism to maintain atomicity to transactions, so the execution of Redis transactions is not atomic.

A transaction can be thought of as a packaged batch execution script, but the batch instruction is not an atomized operation, and the failure of one instruction in the middle does not cause the rollback of previous instructions, nor does it cause subsequent instructions to fail.

Redis 127.0.0.1:7000 > multi

OK

Redis 127.0.0.1:7000> set a aaa

QUEUED

Redis 127.0.0.1:7000> set b BBB

QUEUED

Redis 127.0.0.1:7000> set C CCC

QUEUED

Redis 127.0.0.1:7000 > exec

  1. OK

  2. OK

  3. OK

How to set ====Redis key expiration time and permanent validity respectively?

Use the EXPIRE and PERSIST commands.

====Redis how to do memory optimization?

Use hashes whenever possible. Hashes use very little memory, so you should abstract your data model into a hash as much as possible. For example, if you have a user object in your Web system, do not set a separate key for the user’s name, last name, email address, and password. Instead, store all of the user’s information in a hash table.

For more interview questions or learning resources, see my home page or comments