Redis – Hash Hexists Command

  • Post author:
  • Post category:Redis
  • Post comments:1 Comment


Redis HEXISTS command is used to check whether a hash field exists or not.

Return Value

Integer reply, 1 or 0.

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

Syntax

Following is the basic syntax of Redis HEXISTS command.

redis 127.0.0.1:6379> HEXISTS KEY_NAME FIELD_NAME

Example

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

This Post Has One Comment

Leave a Reply