Easy Tutorial
❮ Pub Sub Psubscribe Sorted Sets Zremrangebyrank ❯

Redis EXISTS Command

Redis Keys

The Redis EXISTS command is used to check if a given key exists.

Syntax

The basic syntax for 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.

Example

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

Now, we create a key named tutorialpro-new-key and assign a value to it, then use the EXISTS command.

redis 127.0.0.1:6379> set tutorialpro-new-key newkey
OK
redis 127.0.0.1:6379> EXISTS tutorialpro-new-key
(integer) 1
redis 127.0.0.1:6379>

Redis Keys

❮ Pub Sub Psubscribe Sorted Sets Zremrangebyrank ❯