tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

Keys

Download
Modo Foco
Tamanho da Fonte
Última atualização: 2026-08-11 11:11:59
Traduzido por IA

Command Introduction

The Keys command family is designed for generic key management operations independent of data type, forming the common lifecycle management foundation for all data structures. Its core commands can be categorized into the following five types based on their features:
Key Creation, Deletion, and Existence Check
DEL: Synchronously deletes one or more keys.
UNLINK: Asynchronously deletes (releases memory in the background to avoid blocking the main thread).
EXISTS: Checks whether one or more keys exist.
TYPE: Returns the data type of a key.
RENAME / RENAMENX: Renames a key (RENAMENX executes only when the target key does not exist).
Expiration Time and Lifecycle Management
EXPIRE / PEXPIRE: Sets a relative expiration time with second or millisecond precision.
EXPIREAT / PEXPIREAT: Sets an absolute expiration time using a UNIX timestamp.
TTL / PTTL: Queries the remaining time to live (TTL) of a key.
PERSIST: Removes the expiration time to make a key permanently valid.
EXPIRETIME / PEXPIRETIME (Redis 7.0+): Returns the expiration timestamp of a key.
Keyspace Traversal and Search
SCAN: Iterates through all database key names incrementally using a cursor, suitable for keyspace exploration in production environments.
KEYS: Returns all key names that match a specified pattern using wildcards (this command blocks the server and should be used with caution in production environments).
RANDOMKEY: Returns a key name randomly.
Key Serialization and Replication
DUMP / RESTORE: Serializes and exports a key-value pair to a binary format and imports it for restoration.
COPY (Redis 6.2+): Copies a key-value pair to a new key name within the same instance.
OBJECT (ENCODING / REFCOUNT / IDLETIME / FREQ / HELP): Views internal information of a key, such as its internal encoding, reference count, and idle time.
Sorting Operations
SORT / SORT_RO: Sorts elements in a list, set, or sorted set and returns the result (SORT_RO is the read-only edition).
For more information, see the Valkey official documentation: Generic (Keys) Command Group.

Command Support Overview

Basic Commands: touch, restore, object, unlink, wait, dump, del, scan, exists, expire, expireat, keys, type, move, ttl, persist, pexpire, pexpireat, pttl, randomkey, rename, renamenx, sort. These commands are supported by the standard architecture and cluster architecture of Redis versions 4.0, 5.0, 6.2, and 7.0, as well as Valkey versions 8.0 and 9.0.
copy, object help commands: These commands are supported only by Redis versions 6.2 and 7.0, and Valkey versions 8.0 and 9.0.
sort_ro, expiretime, pexpiretime commands: These commands are supported only by Redis version 7.0 and Valkey versions 8.0 and 9.0.
delifeq command: This command is supported only by Valkey 9.0.
Cross-Slot Restriction: In a cluster architecture, commands that support cross-slot operations are del and exists. Commands that do not support cross-slot operations are unlink, rename, and renamenx.
Note:
The migrate command is not supported in any version or architecture.
The expire command supports the optional parameters NX, XX, GT, and LT.
NX: sets a value only if the key has no expiration time.
XX: sets a value only if the key has an expiration time.
GT: sets a value only if the new expiration time is greater than the current time.
LT: sets a value only if the new expiration time is less than the current time.

Command Compatibility Matrix

The support status of Keys 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
Cluster Architecture Cross-Slot Support
delifeq
touch
restore
object
object help
unlink
x
wait
migrate
dump
del
scan
exists
expire
expireat
keys
type
move
ttl
persist
pexpire
pexpireat
pttl
randomkey
rename
renamenx
sort
sort_ro
copy
expiretime
pexpiretime

Ajuda e Suporte

Esta página foi útil?

comentários