Redis Multi-database operations

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.