tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Sets Group

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-08-11 11:11:58
AI翻訳

Command Introduction

The Sets command family is designed to operate on unordered, non-repeating string collections. It is suitable for scenarios that require quickly determining membership and performing set operations, such as tag systems, mutual friend queries in social relationships, deduplication, and prize pools. Its core commands can be categorized into the following four types based on their features:
Add, Remove, and Query Members
SADD: Adds one or more members to a set.
SREM: removes specified members.
SISMEMBER / SMISMEMBER: Checks whether a single member or multiple members exist.
SMEMBERS: Returns all members of a set.
SCARD: Returns the cardinality of a set (the total number of members).
SSCAN: iterates through a large set incrementally using a cursor.
Random Operations
SRANDMUNDER: Returns one or more members randomly (without removal).
SPOP: Pops one or more members randomly (with removal), suitable for prize pool scenarios.
Operations Between Sets
SINTER / SUNION / SDIFF: Performs intersection, union, and difference operations respectively.
SINTERSTORE / SUNIONSTORE / SDIFFSTORE: Stores the operation result into a new key.
SMOVE: Moves a member from one set to another.
Enhanced Commands for Higher Versions (Redis 7.0+ / Valkey 8.0+)
SINTERCARD: Quickly counts the cardinality of an intersection without returning the full result, suitable for scenarios where only the intersection size is needed and all members do not need to be obtained.
For more information, see the Valkey official documentation: Set Command Group.

Command Support Overview

Basic Commands: sadd, scard, sdiff, sdiffstore, sinter, sinterstore, sismember, smembers, smove, spop, srandmember, srem, sscan, sunion, sunionstore. These commands are supported by the standard architecture of Redis 2.8 and versions 4.0, 5.0, 6.2, 7.0, as well as the standard architecture and cluster architecture of Valkey 8.0 and 9.0.
smismember command: is supported only by Redis versions 6.2 and 7.0, and Valkey versions 8.0 and 9.0.
sintercard command: is supported only by Redis version 7.0, and Valkey versions 8.0 and 9.0.
Cross-Slot Restriction: In a cluster architecture, sdiff, sdiffstore, sinter, sinterstore, smove, sunion, and sunionstore do not support cross-slot operations.

Command Compatibility Matrix

The support status of Set 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 in Cluster Architecture
sadd
scard
sdiff
sdiffstore
sinter
sinterstore
sismember
smembers
smove
spop
srandmember
srem
sscan
sunion
sunionstore
smismember
sintercard

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック