Redis QuickStart-Redis transactions (13)

Source: Internet
Author: User

Redis transactions let a set of commands execute in a single step. There are two properties in the transaction, which are described below:

    • All commands in a transaction are executed sequentially as a single, independent operation. This is not possible, and requests made to another client are held during the execution of the Redis transaction.
    • Redis transactions are also atomic. An atom means that either all commands are executed, or none are processed.

Example

The Redis transaction is started by the instruction MULTI, and then the transaction is passed, and the entire transaction executes after executing the command, executing a list of commands.

Redis 127.0.0.1:6379> MULTI

Ok

List of commands here

Redis 127.0.0.1:6379> EXEC

Example

Here's an example of how Redis's bookstore is started and executed.

Redis 127.0.0.1:6379> MULTI

Ok
Redis 127.0.0.1:6379> Set Tutorial Redis

QUEUED

Redis 127.0.0.1:6379> GET Tutorial

QUEUED

Redis 127.0.0.1:6379> INCR Visitors

QUEUED

Redis 127.0.0.1:6379> EXEC

1) OK

2) "Redis"

3) (integer) 1

Redis Transaction Instructions

As shown in the following table, there are some basic commands related to Redis transactions:

S.N. Commands & Instructions
1

DISCARD

After issuing the command MULTI discard all

2

Exec

MULTI All commands are issued after the execution line

3

MULTI

Mark the beginning of a transaction block

4

Unwatch

Cancel all the corresponding focus keys

5

WATCH key [Key ...]

Focus on the given item to determine the execution of the multi/exec block

Redis QuickStart-Redis transactions (13)

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.