Redis EXISTS Command

Redis key (clave)

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 Versions

>= 1.0.0

Return Value

Returns 1 if the key exists, otherwise returns 0.

Example

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

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

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

Redis key (clave)

Other extensions