tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Hash Group Keys

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

Command Introduction

The Hash command family is designed to operate on the field-value mapping structure within a key, making it suitable for storing structured data such as user profiles and configuration items in a "one key = one object" manner. Its core commands can be categorized into the following four types based on their features:
Reading, Writing, and Deleting Fields
HSET / HMSET: sets the value of one or more fields.
HGET / HMGET / HGETALL: reads a single field, multiple fields in batches, or all field-value pairs.
HDEL: deletes specified fields.
HSETNX: sets a value only if the field does not exist.
Querying and Counting Fields
HEXISTS: checks whether a field exists.
HLEN: returns the number of fields.
HKEYS / HVALS: returns all field names or all field values, respectively.
HSCAN: iterates through fields in a large Hash incrementally using a cursor to avoid the blocking caused by a one-time HGETALL.
Atomic Counters
HINCRBY / HINCRBYFLOAT: atomically increments a numeric field, making it suitable for multi-dimensional counter scenarios such as user points and product inventory.
Enhanced Commands for Higher Versions (Redis 6.2+ / Valkey 8.0+)
HRANDFIELD: randomly returns one or more fields, making it suitable for sampling and random recommendation scenarios.
For more information, see the Valkey official documentation: Hash Command Group.

Command Support Overview

Basic Commands: hdel, hexists, hget, hgetall, hincrby, hincrbyfloat, hkeys, hlen, hmget, hmset, hset, hsetnx, hstrlen, hvals, hscan. These commands are supported by the standard architecture of Redis versions 2.8, 4.0, 5.0, 6.2, and 7.0, as well as the standard and cluster architectures of Valkey versions 8.0 and 9.0.
hrandfield command: is supported only by Redis versions 6.2 and 7.0, and Valkey versions 8.0 and 9.0.
Field-Level Expiration Commands: hexpire, hpexpire, hexpireat, hpexpireat, hexpiretime, hpexpiretime, httl, hpttl, hpersist, hsetex, hgetex, hgetdel. These commands are supported only by Valkey 9.0.
Cross-Slot Restriction: In a cluster architecture, a command is not supported if its operation involves Hash keys distributed across multiple different slots.

Command Compatibility Matrix

The support status of Hash 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
hdel
hexists
hget
hgetall
hincrby
hincrbyfloat
hkeys
hlen
hmget
hmset
hset
hsetnx
hstrlen
hvals
hscan
hrandfield
hexpire
hpexpire
hexpireat
hpexpireat
hexpiretime
hpexpiretime
httl
hpttl
hpersist
hsetex
hgetex
hgetdel

도움말 및 지원

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

피드백