Introduction
HKEYS and HVALS help you get all the keys or all the values stored inside a Redis hash. This makes it easy to see what data is inside without knowing each key.
HKEYS key HVALS key
HKEYS user:1000HVALS user:1000HMSET user:1000 name "Alice" age "30" city "Paris" HKEYS user:1000 HVALS user:1000
HKEYS myhash return?HKEYS is used to get all the field names (keys) from a Redis hash.HKEYS myhash, it returns all the keys inside myhash, not the values or count.myhash -> Option Auser:100?HVALS.HVALS keyname, so HVALS user:100 is correct. Parentheses are not used in Redis commands.product:1 with fields and values:{"name": "Pen", "color": "blue", "price": "1.5"}HVALS product:1 return?HKEYS myhash but get an empty list even though you know myhash has data. What could be the problem?myhash is not a hash but a string or other type, HKEYS returns an empty list.HVALS would return values, not empty list. Server down causes connection errors, not empty list. An empty hash would return empty list but question says it has data.myhash is not a hash type but a string or other type -> Option Csession:123 but only want the values that are not empty strings. Which approach using HKEYS and HVALS is best?Pass the test and this pattern moves unknown