Latest web development tutorials

Redis Script Exists command

Redis script

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

grammar

redis Script Exists basic command syntax is as follows:

redis 127.0.0.1:6379> EVALSHA sha1 numkeys key [key ...] arg [arg ...] 

Available versions

> = 2.6.0

return value

A list that contains 0 and 1, the former said the script does not exist in the cache, which represents a script already in the cache.

Elements in the list and given SHA1 checksum maintained correspondence, such as the value of the third element of the list, says the third SHA1 checksum script specified in the state in the cache.

Examples

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 script