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

What kind of data is stored in redis?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article shows you what kind of data is stored in redis. The code is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Five data types commonly used in redis

1. String string:

String type is the most basic data storage type in Redis, which is a sequence of bytes. It is binary safe in Redis, which means that this type can accept data in any format, such as JPEG image data, Json object description information, etc., is a standard key-value, generally to store strings, integers and floating-point numbers. The maximum length of data that Value can hold is 512MB

Application scenarios: very common scenarios are used to count the number of website visits, the current number of people online, and so on. Incr command (+ + operation)

two。 List list:

The list of Redis allows users to push in or pop elements from both ends of the sequence. The list is an ordered and repeatable sequence of multiple string values, which is a linked list structure, so the time complexity of adding elements to both ends of the list is 0 (1). The closer the elements are, the faster it is to get them. This means that even if it is a list of tens of millions of elements, it is extremely fast to get 10 records from the head or tail. The maximum number of elements that can be contained in a List is 4294967295.

Application scenarios: 1. The list of the latest news. two。 Message queuing to complete message exchange between multiple programs. You can use the push operation to store the task in the list (producer), and then the thread is taking the task out for execution with the pop operation. (consumer)

3. Hash hash:

Hashes in Redis can be thought of as map containers with String key and String value, and multiple key-value can be stored in a single key. Each Hash can store 4294967295 key-value pairs.

Application scenarios: such as storing, reading, modifying user attributes (name,age,pwd, etc.)

4. Collection set:

The collection of Redis is unordered and unrepeatable, and like lists, it is efficient to perform inserts and deletions and to determine whether an element exists. The biggest advantage of set is that it can perform intersection and difference set operation. The maximum number of elements that a Set can contain is 4294967295.

Application scenarios: 1. Use intersection to find common friends. two。 Using uniqueness, you can count all individual IP visits to the site. 3. When recommended by friends, you can find the intersection according to tag. If it is greater than a certain threshold (critical value), you can recommend it.

The above content is what kind of data is stored in redis? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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