Redis Script Exists Command
The Redis Script Exists command is used to check if a specified script has already been saved in the cache.
Syntax
The basic syntax for the redis Script Exists command is as follows:
SCRIPT EXISTS sha1 [sha1 ...]
Available Versions
= 2.6.0
Return Value
A list containing 0 and 1, where 0 indicates that the script is not in the cache, and 1 indicates that 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 status of the script specified by the third SHA1 checksum in the cache.
Example
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 # Flush the cache
OK
redis 127.0.0.1:6379> SCRIPT EXISTS 232fd51614574cf0867b83d384a5e898cfd24e5a
1) (integer) 0