Sword redis supplement

Source: Internet
Author: User

 
Redis key)The redis key command is used to manage redis keys. Redis has a key for any data type--Redis command for deleting keys> Del key
Redis transactionsRedis transactions can execute multiple commands at a time with the following three important guarantees:1Batch operations are put into the queue cache before sending the EXEC command.2. After the exec command is received, the transaction is executed. If any command in the transaction fails, the remaining commands are still executed.3. During transaction execution, the command requests submitted by other clients are not inserted into the transaction execution command sequence. The execution of a single redis command is atomic, but redis does not add any mechanism to maintain Atomicity in transactions, so the execution of redis transactions is not atomic. Transactions can be understood as a packaged batch execution script, but batch commands are not atomic operations. Failure of a certain command in the middle won't lead to rollback of the previous commands, it will not cause subsequent instructions to be skipped.
 Redis DatabaseRedis supports multiple databases, and the data in each database is isolated and cannot be shared. It is only available on a single machine. If it is a cluster, there is no concept of a database. Redis is a storage server with a dictionary structure. In fact, a redis instance provides multiple dictionaries for storing data. The client can specify the dictionary in which the data is stored. This is similar to the well-known ability to create multiple databases in a relational database instance. Therefore, each dictionary can be understood as an independent database. Each database is named by an incremental number starting from 0. By default, redis supports 16 databases (you can use the configuration file to support more and no upper limit ), you can modify this number by configuring databases. After the client establishes a connection with redis, database No. 0 is automatically selected, but you can use the SELECT command to change the database at any time. To select database No. 1: Command Line syntax -- Select database redis > Select 1  Okredis [  1 ]> Get Foo (NiL), however, these databases named after numbers are different from the databases we understand. Redis does not support user-defined database names. Each database is named by number. Developers must record which databases store the data themselves. In addition, redis does not support setting different access passwords for each database. Therefore, a client can either access all the databases or access one database. The most important thing is that multiple databases are not completely isolated. For example, the flushall command can clear data in all databases in a redis instance. To sum up, these databases are more like namespaces than suitable for storing data of different applications. For example, you can use database 0 to store data in an application production environment and database 1 to store data in the test environment, however, it is not suitable for database 0 to store the data of application a and database B's data. Different applications should use different redis instances to store data. Because redis is very lightweight, an empty redis instance only occupies about 1 MB, so there is no need to worry that multiple redis instances will occupy a lot of memory. 

 

Sword redis supplement

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.