Database / REDIS
What is a Redis Hash used for?
A Hash stores a set of field-value pairs under a single key, similar to a small object or a row in a table — instead of serializing an entire object into one string value, a Hash lets you store and update individual fields of that object directly.
HSET user:1001 name "Alex" age "30" email "alex@example.com" HGET user:1001 name HGETALL user:1001 HINCRBY user:1001 age 1
The practical benefit over storing a JSON-encoded string is field-level access: updating just the age field via HSET or HINCRBY doesn't require reading, deserializing, modifying, and rewriting the entire object, which matters both for network efficiency and for avoiding lost updates if multiple clients touch different fields of the same record concurrently. Hashes are commonly used to represent an entity like a user profile, a product, or a configuration set, where individual attributes are read or updated independently of each other.
More Related questions...
