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 is the database concept of Redis?

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the relevant knowledge of "what is the database concept of Redis". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "what is the database concept of Redis" can help you solve the problem.

First, the origin of 16 databases Redis is a dictionary structure storage server, a Redis instance provides multiple dictionaries for storing data, and the client can specify which dictionary to store the data in. This is similar to creating multiple databases in a relational database instance (as shown in the following figure), so each of these dictionaries can be understood as a separate database.

Take the MySQL instance as an example, Redis supports 16 databases by default. You can modify this value by adjusting the databases in the configuration file redis/redis.conf of Redis. Restart Redis after setting to complete the configuration.

Database 0 is selected by default after the client establishes a connection with Redis, but the database can be replaced at any time using the SELECT command. In an actual project, you can specify the database in the form of a Redis configuration file, as shown in the following figure

Second, correctly understand the concept of "database" in Redis because Redis does not support the name of a custom database, so each database is named by a number. Developers need to record the corresponding relationship between the stored data and the database. In addition, Redis does not support setting a different access password for each database, so either a client can access all databases, or all databases do not have permission to access. However, to correctly understand Redis's concept of "database", one command has to be mentioned here:

This command clears all database data under the instance, which is different from the relational database that we are familiar with. Multiple libraries in a relational database are often used to store data from different applications, and there is no way to empty all library data under an instance at the same time. So for Redis, these db are more like namespaces and are not suitable for storing data from different applications. For example, database 0 can be used to store data in the production environment of an application, and database 1 can be used to store data in the test environment, but it is not suitable to use database 0 to store data in application An and database B in database 1. Different applications should use different Redis instances to store data. Redis is very lightweight, and an empty Redis instance takes up only about 1m of memory, so don't worry about multiple Redis instances taking up a lot of extra memory. 3. Does it support multiple db for one instance in the case of a cluster? Note that the above is based on a single Redis. Using the select command to switch db is not supported in the cluster case, because there is only one db0 in Redis cluster mode. Further expand some of the differences between cluster and stand-alone Reids, interested friends can consult the relevant information for in-depth understanding, there will be no discussion here. Key batch operation support is limited: for example, mget, mset must support in one slotKey transaction and Lua support is limited: the key of operation must be at one node key is the minimum granularity of data partition: does not support bigkey partition does not support multiple databases: only one db0 replication supports one tier in cluster mode: does not support tree replication structure on "what is the database concept of Redis", this ends here Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

Internet Technology

Wechat

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

12
Report