HGET command in redis

HGET key field

If the key holds a hash, retrieve the value associated with the specified field.

If the field is not found or the key does not exist, a special 'nil' value is returned.

TIME COMPLEXITY: O(1)

RETURN VALUE: Bulk reply

Syntax:

HGET KEY_NAME FIELD_NAME

Example 1: When the key and field are present.

redis:6379> HGET myhash field
"1000"

Output

"1000"


Example 2: When the key or field is not present.

redis:6379> HGET myhash field1
(nil)

Output

nil

No comments:

Post a Comment