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:

====Redis features?

Redis is an in-memory cache database developed by Italian Salvatore Sanfilippo (online name: Antirez). Redis full name:

Remote Dictionary Server (Remote Data Service), the software written in C language, a typical NoSQL database Server, Redis is

A key-value storage system that supports rich data types, such as String, list, set, zset(sorted set), and hash.

Redis is essentially a key-value in-memory database, much like memcached, where the entire database is loaded and manipulated.

Periodically flush database data asynchronously to hard disks for saving. Because it is pure memory operation, Redis performance is very good, per second

It processes more than 100,000 read/write operations and is the fastest key-value DB.

Redis is not only outstanding in performance, the biggest charm of Redis is that it supports saving multiple data structures, in addition, the maximum limit of a single value is

1GB. Unlike memcached, which can only store 1MB of data, Redis can also set expire times for stored key-values.

The main disadvantage of Redis is that the database capacity is limited by physical memory and cannot be used as high-performance read and write for massive data. Therefore, Redis is suitable for scenarios

Limited to high performance operations and operations with small amounts of data.

==== Why does Redis need to put all data in memory?

Redis reads data to memory for the fastest read/write speed and writes data to disk asynchronously. So Redis has fast sum

Characteristics of data persistence. If data is not kept in memory, disk I/O speed severely affects Redis performance. In a world where memory is getting cheaper,

Redis will become more and more popular. If the maximum memory usage is set, new values cannot be inserted after the number of existing records reaches the memory limit.

What are the common performance issues with ====Redis? How to solve it?

(1) The Master writes the memory snapshot, and the save command schedules the rdbSave function, which will block the work of the main thread. When the snapshot is large, the performance will be affected

It is best not to write to the memory snapshot.

(2) Master AOF persistence, if you do not rewrite the AOF file, this method of persistence is the least impact on performance, but the AOF file will continue

If the AOF file is too large, it will affect the recovery speed of the Master restart. It is best for the Master not to do any persistent work, including memory snapshots and AOF days

In particular, do not enable memory snapshot for persistence. If data is critical, a Slave will enable AOF backup and synchronize data once per second

Times.

(3) The Master calls BGREWRITEAOF to rewrite the AOF file. AOF will occupy a large amount of CPU and memory resources during the rewrite, resulting in service

The load is too high and the service is temporarily suspended.

(4) Performance problems of Master/Slave replication in Redis. For the speed of Master/Slave replication and connection stability, the Slave and Master had better be in the same LAN.

What are the best scenarios for ====Redis?

(1) Session Cache

(2) Full page Cache (FPC)

(3) Queue

(4) Leaderboards/counters

Publish/subscribe

What are the differences between ====Memcache and Redis?

(1) Different storage methods. Memcache stores all data in memory. Data cannot exceed the size of memory. Redis is partially stored on hard disk to ensure data persistence.

(2) Different types of data support Memcahe data type support is relatively simple, Redis has complex data types.

(3) Different underlying models are used. The underlying implementation modes between them and the application protocols for communication with clients are different. Redis directly built the VM mechanism itself, because normal system calls to system functions would waste a certain amount of time moving and requesting.

Redis can be up to 1GB, while memcache is only 1MB.

What kinds of data structures does ====Redis have? And how to use it?

Redis has five data structures, which are as follows:

String, the String

String data structures are simple key-values, which can be either a String or a number (when the number type is Long)

Encoding is an integer, and everything else is stored in SDSHDR as a string.

Use: get, set, del, INCr, decr, etc

` 127.0.0.1:6379 > set hello world

OK

127.0.0.1:6379 > get the hello

“world”

127.0.0.1:6379 > del hello

(integer) 1

127.0.0.1:6379 > get the hello

(nil)

127.0.0.1:6379 > get counter

“2”

127.0.0.1:6379 > incr counter

(integer) 3

127.0.0.1:6379 > get counter

“3”

127.0.0.1:6379 > 100 incrby counter

(integer) 103

127.0.0.1:6379 > get counter

“103”

127.0.0.1:6379 > decr counter

(integer) 102

127.0.0.1:6379 > get counter

“102” `

Hash – dictionary

In Memcached, we often package some structured information into a HashMap, which is serialized by the client and stored as a string of values (usually

JSON format), such as the user’s nickname, age, gender, points, and so on.

All hash commands are hget, hset, and hdel starting with H

127.0.0.1:6379> hset user name1 hao

(integer) 1

127.0.0.1:6379> hset user email1 [email protected]

(integer) 1

127.0.0.1:6379 > hgetall user

  1. “name1”

  2. “hao”

  3. “email1”

  4. [email protected]

127.0.0.1:6379 > hget user user

(nil)

127.0.0.1:6379 > hget user name1

“hao”

127.0.0.1:6379> hset user name2 xiaohao

(integer) 1

127.0.0.1:6379> hset user email2 [email protected]

(integer) 1

127.0.0.1:6379 > hgetall user

  1. “name1”

  2. “hao”

  3. “email1”

  4. [email protected]

  5. “name2”

  6. “xiaohao”

  7. “email2”

  8. [email protected]

List the List –

List is simply a linked List (Redis uses a List of double-entailed lists), and anyone who has studied data structures should be able to understand its structure. Use:

Lpush + lpop = Stack (Stack)

Lpush +rpop=Queue

Lpush + LTRIM =Capped Collection

Lpush + brPOP =Message Queue

127.0.0.1:6379> lpush myList 12 ll ls mem

(integer) 5

127.0.0.1:6379> lrange myList 0-1

  1. “mem”

  2. “ls”

  3. “ll”

  4. “2”

  5. “1”

The Set collection –

A Set is a Set, and the concept of a Set is a collection of values that are not repeated. Using the Set data structure provided by Redis, you can store collections

Use: All commands start with sadd, srem, scard, smembers, sismember data.

127.0.0.1:6379> sadd mySet hao hao1 haohao

(integer) 3

127.0.0.1:6379 > SMEMBERS myset

  1. “xiaohao”

  2. “hao1”

  3. “hao”

127.0.0.1:6379 > SISMEMBER myset hao

(integer) 1

ZSet — Ordered set

Compared with Set, Zset adds a weight parameter score to elements in Set, so that elements in the Set can be arranged in order according to score

The column,

Use: Ordered collection commands all start with Z zadd, zrange, zscore

127.0.0.1:6379> myscoreset 100 hao 90 xiaohao

(integer) 2

127.0.0.1:6379> ZRANGE myscoreset 0-1

  1. “xiaohao”

  2. “hao”

127.0.0.1:6379 > ZSCORE myscoreset hao

“100”

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