For example a Redis data from different applications to store it?

Redis supports multiple databases, each database and the data can not be shared is isolated, and only stand-alone basis, if there is no concept of a cluster database.

Redis storage server is a dictionary structure, a fact Redis example provided for storing a plurality of dictionary data, the client can specify which data is stored in the dictionary. This is our well-known example of a relationship in the database can be created similar to multiple databases, so it can be one of each dictionary are understood as a separate database.

Each database is a named from outside incrementing number starting at 0, Redis default supports 16 database (more can be supported by the configuration file, no upper limit), you can change this by modifying databases property redis.conf profile digital.

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 16

 

Redis establish client and will automatically select the database connection is 0, but you can always use the SELECT command to replace the database, the database To select No.1:

1 redis> SELECT 1
2 OK
3 redis [1] > GET foo
4 (nil)

 

However, these figures named in a database and differ with our understanding of the database. First name Redis does not support custom databases, each database named with numbers, which the developer must own records database which stores the data. In addition Redis does not support setting a different password for each database access, so a client can either access the entire database, or even a database did not have permission to access. The most important thing is not completely isolated between multiple databases, such as FLUSHALL command to clear all data in one instance Redis database. Taken together, these databases is more of a namespace, is not suitable for storing data of different applications. Such data number 0 may be used an application database stores production environment, using the data stored in the database No. 1 in the test environment, but not suitable for using the data stored in a database application No. 0 A and B using the database application data # 1, except applications should use different Redis instance store data. Since Redis very lightweight, occupying an empty Redis instance intrinsic only about 1M, so do not worry multiple instances extra Redis take up a lot of memory.

 

Guess you like

Origin www.cnblogs.com/jun1019/p/10987911.html