Under Redis, a database is identified by an integer index, not by a database name. By default, one client connects to database 0. The following parameters in the Redis configuration file control the total number of databases: Databases 16 [[email protected] ~]#/opt/redis/bin/redis-cli-p 6379127.0.0.1:6379> keys) "List" 127.0.0.1:6379> select 1ok127.0.0.1:6379[1]> keys * (empty list or set) Subsequently, All commands will use database 1, knowing that you explicitly switch to another database. Each database has its own space, and there is no need to worry about key conflicts. Under different databases, the same key is taken to the respective value. 127.0.0.1:6379[1]> set list ' This was a list ' ok127.0.0.1:6379[1]> get list "This is a list" 127.0.0.1:6379[1]> Selec T 0ok127.0.0.1:6379> get List "1,2,3,4,5,6,7,8,9,10"  FLUSHDB command clears the data, only clears the data under the current database and does not affect other databases. 127.0.0.1:6379[1]> flushdbok127.0.0.1:6379[1]> get list (nil) 127.0.0.1:6379[1]> keys * (empty list or set) The flushall command clears the data for this instance. Take extra care before executing this command. 127.0.0.1:6379> Select 1ok127.0.0.1:6379[1]> Set list ' This was a list ' ok127.0.0.1:6379[1]> get list ' This is a LIS T "127.0.0.1:6379[1]> flushallok127.0.0.1:6379[1]> Keys * (empty list or set) 127.0.0.1:6379[1]> Select 0ok127.0.0.1:6379> keys * (empty list or setThe number of databases is configurable and is 16 by default. Modify the Databases directive under REDIS.CONF: Databases 64
Redis Multi-database operations