Redis - Keys Exists Command


Advertisements

Redis EXISTS command is used to check whether the key exists in Redis or not.

Return Value

Integer value

  • 1, if the key exists.
  • 0, if the key does not exist.

Syntax

Following is the basic syntax of Redis EXISTS command.

redis 127.0.0.1:6379> EXISTS KEY_NAME

Example

redis 127.0.0.1:6379> EXISTS tutorialspoint-new-key 
(integer) 0

Now, create a key with the name tutorialspoint-new-key and check for its existence.

redis 127.0.0.1:6379> EXISTS tutorialspoint-new-key 
(integer) 1
redis_keys.htm
Advertisements