Latest web development tutorials

Redis EXISTS command

Redis key (key)

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

grammar

redis EXISTS basic command syntax is as follows:

redis 127.0.0.1:6379> EXISTS KEY_NAME

Available versions

> = 1.0.0

return value

If the key exists returns 1, otherwise it returns 0.

Examples

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

Now we create a w3big-new-key and key name assignment, then use EXISTS command.

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

Redis key (key)