tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Transactions

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-08-11 11:11:59
AI 번역

Command Introduction

The Transactions command family is designed to encapsulate multiple commands into an atomic execution unit. It is suitable for scenarios that require atomicity for batch operations, such as inventory deduction and account balance transfers. Based on their features, its core commands can be categorized into the following two types:
Transaction Lifecycle Control
MULTI: Marks the start of a transaction, and subsequent commands enter a queued state.
EXEC: Submits and executes all commands in the transaction queue at once and in order (the execution is not interrupted by requests from other clients during this process).
DISCARD: Aborts the transaction and clears all queued commands.
Optimistic Locking Concurrency Control
WATCH: Monitors one or more keys before a transaction starts. If a monitored key is modified by another client before EXEC, the transaction is automatically aborted (returns nil), thereby implementing the CAS (Compare-And-Swap) optimistic locking mechanism.
UNWATCH: Cancels the monitoring of all keys on the current connection.
Note:
Unlike relational databases, Redis/Valkey transactions do not provide rollback capability. Their atomicity is only reflected in the execution phase: commands within a transaction are packaged and executed at once, and the execution is not interrupted by requests from other clients. If an error occurs while executing a command, subsequent commands will still be executed, and operations that have already been executed will not be rolled back.
For more information, see the Valkey official documentation: Transactions Command Group.

Command Support Overview

All five commands (discard, exec, multi, unwatch, watch) are fully supported in the standard architecture of Redis versions 2.8, 4.0, 5.0, 6.2, and 7.0, as well as in the standard and cluster architectures of Valkey versions 8.0 and 9.0.
Cross-Slot Restriction: Transactions family commands do not involve cross-slot access scenarios.

Command Compatibility Matrix

The support status of Transactions family commands across different versions and architectures is shown in the table below (✓ indicates supported, ✗ indicates not supported, and — indicates that the command does not involve a cross-slot access scenario).
Command
Valkey 9.0 Standard Architecture
Valkey 9.0 Cluster Architecture
Redis 7.0/Valkey 8.0 Standard Architecture
Redis 7.0/Valkey 8.0 Cluster Architecture
Redis 6.2 Standard Architecture
Redis 6.2 Cluster Architecture
Redis 5.0 Standard Architecture
Redis 5.0 Cluster Architecture
Redis 4.0 Standard Architecture
Redis 4.0 Cluster Architecture
Redis 2.8 Standard Architecture
Cross-Slot Support for Cluster Architecture
discard
exec
multi
unwatch
watch

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백