Home » Redis Hashes

Redis Hashes

Redis Hashes are the perfect data type to represent objects. They used to map between the string fields and the string values. In Redis, every hash can store up to more than 4 billion field-value pairs.

Example

redis 127.0.0.1:6379> HMSET tutoraspire name “A solution to all Technology” description “India’s fastest growing tutorial website” daily 1 million visitors 10 millions page visit.

Redis Hashes 1
Redis Hashes 2

In the above example, “tutoraspire” is Redis hash which contains the details (name, description, 1, million, 10, vistiors, page, visit) etc.


Redis Hash Commands

IndexCommandDescription
1HDEL key field2 [field2]It is used to delete one or more hash fields.
2HEXISTS key field It is used to determine whether a hash field exists or not.
3HGET key field It is used to get the value of a hash field stored at the specified key.
4HGETALL key It is used to get all the fields and values stored in a hash at the specified key
5HINCRBY key field increment It is used to increment the integer value of a hash field by the given number
6HINCRBYFLOAT key field increment It is used to increment the float value of a hash field by the given amount
7HKEYS key It is used to get all the fields in a hash
8HLEN key It is used to get the number of fields in a hash
9HMGET key field1 [field2] It is used to get the values of all the given hash fields
10HMSET key field1 value1 [field2 value2 ] It is used to set multiple hash fields to multiple values
11HSET key field value It is used to set the string value of a hash field
12HSETNX key field value It is used to set the value of a hash field, only if the field does not exist
13HVALS key It is used to get all the values in a hash

Next TopicRedis Lists

You may also like