In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Why does redis support multiple databases? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Note: Redis supports multiple databases, and the data in each database is isolated and cannot be shared, and it is based on a stand-alone machine. If it is a cluster, there is no database concept.
The reason why redis is divided into so many databases is also to distinguish businesses. Different businesses are stored in different databases, but a redis is usually used for a project, and different businesses within the project use a separate database, so that there will be no data overlap.
Redis is a dictionary-structured storage server, but in fact an Redis instance provides multiple dictionaries for storing data, and the client can specify which dictionary to store the data in. This is similar to the well-known fact that multiple databases can be created in a relational database instance, so each dictionary can be understood as a separate database.
Each database is externally named with an incremental number starting from 0. Redis supports 16 databases by default (more can be supported through configuration files, no upper limit). You can modify this number by configuring databases. The client automatically selects database 0 after establishing a connection with Redis, but you can use the SELECT command to change the database at any time. To select database 1:
Redis > SELECT 1OKredis [1] > GET foo (nil)
However, these databases named after numbers are different from those we understand.
First of all, Redis does not support custom database names, each database is named by a number, and developers must record which databases store which data.
In addition, Redis does not support setting a different access password for each database, so a client can either access all databases or do not even have permission to access one database.
The most important point is that multiple databases are not completely isolated. For example, the FLUSHALL command can empty the data in all databases in a Redis instance.
To sum up, these databases are more like a namespace than 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.
Because Redis is very lightweight, an empty Redis instance takes up only about 1m, so you don't have to worry about multiple Redis instances taking up a lot of extra memory.
This is the answer to the question about why redis supports multiple databases. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.