Reading — step 1 of 3
Managing Hashes
~1 min readHashes
HDEL & HGETALL — Managing Hashes
Commands
HDEL key field [field ...]— delete fields, return count deletedHGETALL key— return all field-value pairs as flat arrayHEXISTS key field—:1or:0HLEN key— number of fields
HGETALL Response Format
Returns a flat RESP array alternating field/value:
HSET user name Alice age 30
HGETALL user → *4\r\n$4\r\nname\r\n$5\r\nAlice\r\n$3\r\nage\r\n$2\r\n30\r\n
Auto-delete
Like lists, when all fields are deleted, the hash key is removed automatically.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…