Redis EXISTS Command
The Redis EXISTS command is used to check whether the given key exists.
Syntax
The basic syntax of the redis EXISTS command is as follows:
redis 127.0.0.1:6379> EXISTS KEY_NAME
Available Version
= 1.0.0
Return Value
Returns 1 if key exists, otherwise returns 0.
Example
redis 127.0.0.1:6379> EXISTS runoob-new-key
(integer) 0
Now we create a key named runoob-new-key and assign a value, then use the EXISTS command.
redis 127.0.0.1:6379> set runoob-new-key newkey
OK
redis 127.0.0.1:6379> EXISTS runoob-new-key
(integer) 1
redis 127.0.0.1:6379>
Redis Key