w3resource

Redis Hash: HEXISTS

HEXISTS key field

Redis HEXISTS command is used to check whether a hash field stored at key or not.

Syntax:

HEXISTS KEY_NAME FIELD_NAME 

Available since

2.0.0.

Return Value

Integer reply, 1 or 0.

Return Value Type

Integer

  • 1, if the hash contains a field.
  • 0 if the hash does not contain a field, or key does not exist.

Example: Redis HEXISTS

127.0.0.1:6379> HMSET langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python"
OK
127.0.0.1:6379> HEXISTS langhash lang1
(integer) 1
127.0.0.1:6379> HEXISTS langhash lang4
(integer) 0

Example: Redis HEXISTS another example

127.0.0.1:6379> HSET user email [email protected]
(integer) 1
127.0.0.1:6379> HEXISTS user email
(integer) 1
127.0.0.1:6379> HEXISTS user xyz
(integer) 0

Previous: HDEL
Next: HGET



Follow us on Facebook and Twitter for latest update.