Redis EXISTS Command
The Redis EXISTS command is used to check whether a 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 Versions
>= 1.0.0
Return Value
Returns 1 if the key exists, otherwise returns 0.
Examples
redis 127.0.0.1:6379> EXISTS example-new-key (integer) 0
Now let's create a key named example-new-key and assign a value, then use the EXISTS command.
redis 127.0.0.1:6379> set example-new-key newkey OK redis 127.0.0.1:6379> EXISTS example-new-key (integer) 1 redis 127.0.0.1:6379>
Other Extensions
Redis key