Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Redis things transaction

Shulou Source: shulou.com Published: 2022-06-02 19:21:07 10月05日 Update

MULTI

Used to mark the beginning of the transaction block. Redis queues subsequent commands one by one before you can use the EXEC command to atomize the sequence of commands.

The running format of this command is as follows:

MULTI

The return value of this command is a simple string, always OK.

EXEC

Execute all previously queued commands in a transaction and then restore the normal connection state.

When using the WATCH command, the EXEC command executes the command in the transaction only if the monitored key has not been modified, which takes advantage of the CAS mechanism.

The running format of this command is as follows:

EXEC

The return value of this command is an array where each element is the return value of each command in the atomized transaction. When using the WATCH command, the EXEC command returns a null value if the transaction execution is aborted.

127.0.1 name Jack age 29QUEUED127.0.0.1:6380 6380 > multiOK127.0.0.1:6380 > xadd myStreamKey * name Jack age 29QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 28QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 27QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 26QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 25QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 24QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 23QUEUED127.0.0. 1RV 6380 > xadd myStreamKey * name Jack age 22QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 21QUEUED127.0.0.1:6380 > xadd myStreamKey * name Jack age 20QUEUED127.0.0.1:6380 > exec 1) "1555926229541-0" 2) "1555926229541-1" 3) "1555926229541-2" 4) "1555926229541-4" 5) "1555926229541-5" 7) "1555926229541-6" 8) "1555926229541-7" 9) "1555926229541-8" 10) "1555926229541-9"

Tags: Commands transactions atoms formats queues runs elements only characters strings sequences arrays methods mechanisms tags status checks monitoring things Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux MariaDB Docker Redmi