Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Script Exists Command

Redis Script Exists Command

Redis Scripting

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

Syntax

The basic syntax of the redis Script Exists command is as follows:



SCRIPT EXISTS sha1 [sha1 ...]

Available Version

= 2.6.0

Return Value

A list containing 0 and 1, where the former means the script is not in the cache and the latter means the script is already in the cache.

The elements in the list correspond to the given SHA1 checksums; for example, the value of the third element in the list indicates the cache status of the script specified by the third SHA1 checksum.

Example



redis 127.0.0.1:6379> SCRIPT LOAD "return 'hello moto'"    # 载入一个脚本

"232fd51614574cf0867b83d384a5e898cfd24e5a"



redis 127.0.0.1:6379> SCRIPT EXISTS 232fd51614574cf0867b83d384a5e898cfd24e5a

1) (integer) 1



redis 127.0.0.1:6379> SCRIPT FLUSH     # 清空缓存

OK



redis 127.0.0.1:6379> SCRIPT EXISTS 232fd51614574cf0867b83d384a5e898cfd24e5a

1) (integer) 0

Redis Scripting