Redis Hexists Command

Redis Hash

The Redis Hexists command is used to check whether the specified field exists in the hash table.

Syntax

The basic syntax of the Redis Hexists command is as follows:

redis 127.0.0.1:6379> HEXISTS KEY_NAME FIELD_NAME 

Available Versions

>= 2.0.0

Return Value

If the hash table contains the given field, return 1. If the hash table does not contain the given field, or the key does not exist, return 0.

Examples

redis 127.0.0.1:6379> HSET myhash field1 "foo"
(integer) 1
redis 127.0.0.1:6379> HEXISTS myhash field1
(integer) 1
redis 127.0.0.1:6379> HEXISTS myhash field2
(integer) 0

Redis Hash

Other Extensions