Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Knowledge introduction of redis cache middleware

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the knowledge of redis cache middleware, which can be used for reference by friends who need it. Let's take a look at redis caching middleware with me.

Basic data structure

String: normal set and get, do simple KV caching, counters, and shared user session.

Hash: similar to Map, it generally stores structured data (simple objects), while the application scenario of Hash is relatively simple (now a bunch of objects are nested inside objects that are not suitable for Hash).

List: ordered list (order when inserted)

Message queuing: producers use Lpush, and multiple consumers use the data at the end of the "grab" list blocked by BRpop.

Article list data paging display: through the lrange command, read a closed range of elements, such as Weibo, swipe down to refresh the page.

Set: unordered sets, automatic deduplication, use set for intersection, union, subtraction operations. Like a mutual friend of two people.

StoredSet: Set with sorting

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

Persistence

RDB: the image is fully persisted, which takes a long time, and the data recovery is fast and not real-time.

AOF: incremental persistence. Every second or every operation is followed by an operation code at the end of the AOF file. It takes a long time to recover the data.

What happens if the power goes out midway?

Depending on the configuration of the AOF log sync property, if you do not pursue performance and sync the disk as each instruction is written, you will not lose data. Timed sync is generally used, such as 1s1 times. At this time, up to 1 second of data will be lost.

RDB principle

Fork and cow,fork means that redis performs RDB operations by creating child processes, and cow refers to copy on write. After the child process is created, the parent process shares the data segment, and the parent process continues to provide read and write services, and the dirty page data will gradually be separated from the child process.

What are the benefits of Pipeline and why do you use it?

The time for multiple IO round trips can be reduced to one, as long as there is no causal relationship between the instructions executed by pipeline. When you use redis-banchmark for stress testing, you can find that an important factor affecting the QPS peak of redis is the number of pipeline batches of instructions.

The above is a brief introduction to redis cache middleware knowledge, of course, the detailed use of the above differences have to be used by everyone to understand. If you want to know more, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report