Redis Hash – Commands to manage a hash value in redis datastore

3 weeks ago Lalit Bhagtani 0

Hash is a map of field-value pair, which can be used to represent object type like java object. In Redis, hash can be store as a value at key and various redis commands are used to store, manage and retrieved a hash value stored in redis database. The syntax for using redis commands is as follows :-

Syntax :-

redis host:post> <Command Name> <key name>

Example :-

Redis HSET

Redis Hash Value Commands :- 

Some of the important commands to manage hash value in redis database are as follows :-

S.No Command Description
1 HDEL Delete fields from hash value
2 HEXISTS Check existence of field in hash value
3 HGET Get value of field in hash value
4 HGETALL Returns all fields and its values contained in hash value
5 HINCRBY Increments integer value of field in hash value
6 HINCRBYFLOAT Increments float value of field in hash value
7 HKEYS Returns all field’s name contained in hash value
8 HLEN Returns number of fields in hash value
9 HMGET Get multiple fields and its respective values contained in hash value
10 HMSET Set multiple values to its respective fields in hash value
11 HSCAN Incrementally iterates hash fields and associated values
12 HSET Set value to its field contained in hash value
13 HSETNX Set value to its field only if field exists
14 HSTRLEN Returns length of field’s value contained in hash value
15 HVALS Returns all values associated with fields contained in hash value

References :-

  1. Hash Command Docs

That’s all for Redis hash value and commands used to store and manage it in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.