Introduction
HSET and HGET let you store and get small pieces of information inside a bigger group, like putting notes in labeled folders.
HSET key field value HGET key field
HSET user:1 name "Alice"
HGET user:1 nameHSET product:100 price 29.99
HGET product:100 priceHSET user:42 age 30 HSET user:42 city "New York" HGET user:42 age HGET user:42 city
HSET do?HSET command is used to store or update a field-value pair inside a Redis hash key, organizing related data together.HGET retrieves values, HDEL deletes fields, and KEYS lists keys, so they do not match the description of HSET.name to John in hash key user:1 using Redis?HSET key field value. Here, key is user:1, field is name, and value is John.HSET user:2 age 30HSET user:2 city LondonHGET user:2 ageage to 30 in user:2. The second sets city to London.HGET user:2 age retrieves the value of field age from user:2, which was set to 30.HGET user:3 email but get (nil) as output. What could be the reason?HGET returns (nil), it means the requested field does not exist in the hash key.(nil). Server down would cause connection errors, and incorrect syntax would cause errors, not (nil).email does not exist in the hash user:3 -> Option Cprofile:100. You run:HSET profile:100 name AliceHSET profile:100 age 0HGET profile:100 age0 is stored as the string "0", which is a valid value.HGET returns the exact stored string. Since age was set to 0, it returns "0", not nil or empty.Pass the test and this pattern moves unknown