Redis – Keys Exists Command

  • Post author:
  • Post category:Redis
  • Post comments:0 Comments

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 Adglob-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 Adglob-new-key 
(integer) 1

Leave a Reply