Skip to main content
Swytch Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Hashes

Store related fields without replacing an entire serialized object on every update.

HSET user:42 name Alice visits 0
HINCRBY user:42 visits 1
HGETALL user:42

Choose hashes for profiles, session attributes, and counters grouped under one key. A single command updates its target fields; several client commands do not become one transaction just because they share a hash.

Use key expiration for the lifetime of the object, or the supported field-expiration commands when fields need different lifetimes. Check the hash command reference for the supported operations.

If multiple workloads access user:42, the hash becomes shared state. Plan for subscriber and transaction costs.