tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

scripting and functions Group

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

Command Introduction

The Scripting and Functions command family is used to execute Lua scripts and manage reusable function libraries on the server side. It is suitable for scenarios that require multi-step atomic operations, reduce network round trips, or implement complex business logic at the data layer. Based on their features, its core commands can be categorized into the following three types:
Lua Script Execution
EVAL / EVALSHA: These commands atomically execute a Lua script on the server side (all operations are completed within the same event loop and cannot be interrupted by other commands). EVAL directly passes the script source code, while EVALSHA invokes a cached script using its SHA1 hash.
EVAL_RO / EVALSHA_RO (Redis 7.0+): This is a read-only replica executable edition, used for read-only script operations on replica nodes.
Script Cache Management
SCRIPT LOAD: This command loads a script into the server-side cache and returns its SHA1 hash.
SCRIPT EXISTS: Checks whether a script exists in the cache.
SCRIPT FLUSH: Flushes all script caches.
SCRIPT KILL: Terminates a long-running script that is currently executing.
Functions Library (Redis 7.0+ / Valkey 8.0+)
The Functions mechanism upgrades scripts into named function libraries, supporting persistent storage and master-replica replication, and providing better maintainability and version management capabilities.
FUNCTION LOAD / FUNCTION DELETE / FUNCTION FLUSH: These commands load, delete, or flush a function library.
FUNCTION LIST / FUNCTION DUMP / FUNCTION RESTORE: These commands list, dump, or restore a function library.
FUNCTION STATS: Views function execution statistics.
FCALL / FCALL_RO: These commands invoke a registered named function. (The RO version can be executed on a read-only replica.)
For more information, see the Valkey official documentation: Scripting Command Group.

Command Support Overview

Basic Commands: eval, evalsha, script exists, script flush, script load, script kill. 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.
Commands Added in 7.0+: eval_ro, evalsha_ro, function delete, function dump, function flush, function kill, function list, function load, function restore, function stats, fcall, fcall_ro. These commands are supported only by Redis version 7.0 and Valkey versions 8.0 and 9.0. Among them, eval_ro and evalsha_ro are versions that can be executed on read-only replicas, while fcall and fcall_ro are used to invoke custom functions.
Globally Unsupported: script debug is not supported by any version or architecture.
Cross-Slot Restriction: In a cluster architecture, the commands eval, evalsha, and script exists do not support cross-Slot operations. The keys involved in the operation must reside on the same Slot.

Command Compatibility Matrix

The support status of Scripting and Functions 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).
Note:
eval_ro and evalsha_ro are read-only commands that can execute Lua scripts on read-only replicas. The function series commands are used to manage Redis custom function libraries. These commands are supported only by Redis version 7.0 and Valkey versions 8.0 and 9.0.
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
eval
eval_ro
evalsha
evalsha_ro
script debug
script exists
script flush
script load
script kill
function delete
function kill
function dump
function flush
function list
function load
function restore
function status
fcall
fcall_ro

ヘルプとサポート

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

フィードバック