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

Sharing of redis starter Learning Manual

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the sharing of redis getting started learning manual, the introduction in the article is very detailed, has a certain reference value, interested friends must read it!

I. Preface

In the past few years, when it comes to high concurrency, massive data storage solutions, we think of NoSQL database, and the corresponding products naturally show vitality. Among the many products, Redis, MongoDB, BerkeleyDB and CouchDB stand out. Let's give a brief explanation.

Advantages of Redis:

1. Compared with other NoSQL products, Redis is extremely easy to use, so developers who have experience with similar products can use Redis to build their own platform in a day or two, or even a few hours later.

2. It not only solves many general problems, but also provides relevant solutions for some personalized problems, such as index engine, statistical ranking, message queue service and so on.

3. The main problems existing in the current version of Redis:

1. Windows platform is not supported in the official version, but only Unix-like and MacOSX-like platforms are supported in the official version that has been released.

2. No cluster support is provided, but according to the official website, this feature is expected to be added in version 2.6.

3. In the Publication/Subscription feature, if master goes down, slave cannot be automatically upgraded to master.

4. Comparison with relational database:

In the current version of Redis (2.4.7), there is support for five different data types, of which there is only one type, that is, the string type can be regarded as a Key-Value structure, while the other data types have application scenarios suitable for their own characteristics. We will explain the details in the blog later in the series.

Compared with relational database, because of its relatively simple storage structure, Redis can not provide good support for complex logical relationships. However, in the scenario suitable for Redis, we can achieve a significant improvement in efficiency. Even so, Redis provides us with some basic concepts that databases should have, such as: you can choose to open different databases in the same connection, but the difference is that databases in Redis are named by numbers, and the open database is 0 by default. If the program is going to switch databases while running, you can use Redis's select command to open other databases, such as select 1, and if you want to switch back to the default database after that, simply execute select 0.

In the aspect of data storage, Redis follows the mainstream idea of the existing NoSQL database, that is, Key as the unique identification of data retrieval, we can simply understand it as the key of the index in the relational database, and Value as the main object of data storage, each Value has a Key associated with it, which is like the location of the physical data in the index stored in the data table. In Redis, Value is treated as a binary byte stream for storing data in any format, such as Json, XML, and serialized object byte streams, so we can also think of it as a BLOB type field in RDB. It can be seen that when querying data, we can only use Key as the condition of our query. Of course, we can also apply some techniques provided in Redis to use Value as the Key of other data, which we will introduce in later blogs.

Fifth, how to persist memory data:

By default, Redis will refer to the amount of data in the current database that has been modified, and after reaching a certain threshold, it will store snapshots of the database to disk, which we can set through the configuration file. In general, we can also set Redis to be saved on a regular basis. For example, when more than 1000 key data are modified, Redis will persist the data every 60 seconds. By default, if there are 9 or less data modifications, Redis will persist every 15 minutes.

As can be seen from the scheme mentioned above, if we adopt this approach, the runtime efficiency of Redis will be very efficient, that is, whenever new data modifications occur, only the cached data in memory will change, and such changes will not be immediately persisted to disk, thus avoiding the occurrence of disk IO in most of the modification operations. However, things often have two sides. In this method, we do get an improvement in efficiency, but lose the reliability of the data. If the server where Redis resides goes down before the memory snapshot is persisted to disk, the modified data that is not written to disk will be lost. In order to ensure the high reliability of data, Redis also provides another data persistence mechanism-Append mode. If the Redis server is configured in this way, it will be persisted to disk immediately whenever a data modification occurs.

The above is all the contents of the article "redis getting started Learning Manual sharing". Thank you for reading! Hope to share the content to help you, more related knowledge, 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

Wechat

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

12
Report