Home > Database > Redis > Introduction to basic knowledge of redis cache middleware

Introduction to basic knowledge of redis cache middleware

Release: 2020-04-14 09:32:08
forward
2638 people have browsed it

Introduction to basic knowledge of redis cache middleware

Basic data structure

  • String: ordinary set and get, simple KV cache, counter and sharing user session.

  • Hash: similar to Map, generally stores structured data (simple objects), Hash has a relatively single application scenario (current objects also have a bunch of objects nested inside, which is not suitable for Hash) .

  • List: ordered list (order when inserting)

Message Queue: Producer passes Lpush, multiple consumers use BRpop blocking "Grab" the data at the end of the list.

Pagination display of article list data: Use the lrange command to read elements within a certain closed range, such as Weibo, slide down to refresh the page.

  • Set: Unordered collection, automatic deduplication, use set to perform intersection, union, and difference operations. For example, two people are mutual friends.

  • StoredSet: Set with sorting

  • BloomFilter implemented by Bit-Map: Bloom filter, which can be used to determine whether it exists in the database this information.

Persistence

RDB: Full image persistence, persistence takes a long time, data recovery speed is fast, and not real-time enough

AOF: Incremental persistence, the operation code is appended to the end of the AOF file every second or every operation, and the data recovery time is slow.

What happens if the power is cut off in the middle?

It depends on the configuration of the sync attribute of the AOF log. If performance is not pursued, the disk will be synced for each write instruction. No data will be lost. Generally, timed sync is used, such as 1s1 time. At this time, at most 1s of data will be lost

RDB principle

fork and cow, fork refers to redis creating a child process For RDB operations, cow refers to copy on write. After the child process is created, the parent and child processes share the data segment. The parent process continues to provide read and write services. The dirty page data written will gradually separate from the child process.

What are the benefits of Pipeline? Why can you use

to reduce the time of multiple IO round-trips to one? The premise is that there is no causal relationship between the instructions executed by the pipeline. Use When redis-banchmark performs stress testing, it can be found that an important factor affecting the QPS peak value of redis is the number of pipeline batch instructions.

For more redis knowledge, please pay attention to the redis introductory tutorial column.

The above is the detailed content of Introduction to basic knowledge of redis cache middleware. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template