The difference of Redis MongoDB multi-database

Source: Internet
Author: User
Tags mongodb redis

Someone asked me, Redis multiple databases, is not the start of multiple Redis processes, listening to different ports. At some level, this can be considered, but not recommended.

1,redis Database

The number of Redis databases is set dead in the configuration file, and the name is not allowed to be changed.

Databases 16//default 16 databases

These 16 database numbers are 0-15, and if the database is not switched, the default is the No. 0 database.

# telnet 127.0.0.1 6379
Trying 127.0.0.1 ...
Connected to 127.0.0.1.
Escape character is ' ^] '.
Set test 123//In database No. 0 setting test to 123
+ok
Select 1//Switch to number 1th database
+ok
Set test 456//Set test to 456
+ok
Get test//1th database test is 456
$
456
Select 0//switch to number NO. 0 database
+ok
Get Test//test is 123
$
123
The same key between databases is not affected by each other.

2,mongodb Database

MongoDB is very much like a relational database, unlike Redis, MongoDB the database name is customized without the number of databases defined beforehand. less restrictive than Redis.
 
# mongo 
MongoDB shell version:2.6.4-pre- 
connecting to:test 
> Use tank/ /tank database exists, switch to tank, and if not, create tank database  
switched to DB tank 

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.