English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Script Exists Command

Redis Scripts

The Redis Script Exists command is used to check whether the specified script has been saved in the cache.

Syntax

Basic Syntax of Redis Script Exists Command

SCRIPT EXISTS sha1 [sha1 ...]

Available Version

>= 2.6.0

Return Value

a list, containing 0 and 1 , the former indicates that the script does not exist in the cache, and the latter indicates that the script is already in the cache.

The elements in the list and the given SHA1 Check and keep the corresponding relationship, for example, the value of the third element in the list represents the third SHA1 Check and specify the script status in the cache.

Online Examples

redis 127.0.0.1:6379> SCRIPT LOAD "return 'hello moto'"    # Load a script
"232fd51614574cf0867b83d384a5e898cfd24e5a"
redis 127.0.0.1:6379> SCRIPT EXISTS 232fd51614574cf0867b83d384a5e898cfd24e5a
1) (integer) 1
redis 127.0.0.1:6379> SCRIPT FLUSH     # Clear Cache
OK
redis 127.0.0.1:6379> SCRIPT EXISTS 232fd51614574cf0867b83d384a5e898cfd24e5a
1) (integer) 0

Redis Scripts