Get the App
SLTechnology News&Howtos  ›  Database  › 

Data types and advantages of Redis cache database

Shulou Source: shulou.com Published: 2022-05-31 18:11:16 10月03日 Update

This article mainly explains "the data types and advantages of Redis cache database". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the data types and advantages of Redis cache database.

Why use Redis when you already have Memcache?

The following disadvantages of Memcache:

Data persistence storage is not supported

Master and slave are not supported

Fragmentation is not supported

Compared to Redis databases, the above three points are supported, so use redis.

Why is redis so fast?

The access speed of Redis can reach 100000 + QPS (querypersecond, number of queries per second).

Based entirely on memory: most of the requests are purely memory operations and are not limited to the hard disk read speed, so the execution efficiency is high.

The data structure is simple, it is (key,value) form, and the operation of the data is also simple.

Using single thread can also handle highly concurrent requests.

Compared with the traditional blocking I _ paw O _ no _ Redis, it uses the multiplex I _ paw O reuse model, and the non-blocking I _ par _ O

It has atomic operation.

The multiplex Istroke O multiplexing function adopted by Redis?

The multiplex functions are: epoll, kqueue, evport, select link: multiplex Icano multiplexing technology.

According to local conditions, some systems only have select.

Give priority to the function with time complexity O (1) as the underlying implementation

Take select with time complexity O (n) as the guarantee.

Listening for Istroke O events based on reactor design pattern

What are the data types of Redis? (key point! )

String: the most basic data type, binary security, can store data in any format (jpg pictures, serialized objects)

A dictionary composed of hash:string elements, suitable for storing objects

List: list, features: FIFO, orderly (in order of addition), repeatable

An unordered collection of set:string elements, implemented through hash, and does not allow repetition

Sortedset: sorts the members of the collection from small to large by scores

HyperLogLog for counting

Used to support Geo for storing geolocation information

The underlying data type foundation of Redis:

1, simple dynamic string; 2, linked list; 3, dictionary; 4, jump table

5. Collection of integers; 6. Compressed list; 7. Objects.

Thank you for your reading, the above is the content of "data types and advantages of Redis cache database". After the study of this article, I believe you have a deeper understanding of the data types and advantages of Redis cache database, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Data type database support advantages cache multiplexing storage functions objects learning complexity elements memory content complexity dictionary underlying layer time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB macOS NVidia OPPO Reno