HSET(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– HSET (3valkey) πŸ’–

okay bestie, welcome to the Valkey Command Manual ✨ β€” this is the hset page and it's honestly iconic. Let's get into it 🫢


🌸 NAME 🌸

hset β€” creates or modifies the value of a field in a hash. that's it, that's the whole vibe πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

HSET key field value [field value ...]

✨ DESCRIPTION ✨

So here's the tea: hset sets the specified fields to their respective values in the hash stored at key πŸ’–

And listen β€” this command overwrites the values of specified fields that already exist in the hash. no hesitation, no second thoughts, it just does it. and if key doesn't exist? boom, a brand new key holding a hash gets created, no cap 🌈


πŸ‘‘ REPLY πŸ‘‘

valkey-protocol(7) Integer reply: the number of fields that were added. like, the new ones. periodt πŸ’…


🧚 COMPLEXITY 🧚

O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs. she's efficient, she's fast, she ate πŸ”₯


πŸ’œ ACL CATEGORIES πŸ’œ

@fast @hash @write


πŸ¦‹ HISTORY πŸ¦‹

  • Available since: 2.0.0
  • Changed in 4.0.0: Accepts multiple field and value arguments.

glow up of the century tbh 🌸


⭐ EXAMPLES ⭐

127.0.0.1:6379> HSET myhash field1 "Hello"
(integer) 1
127.0.0.1:6379> HGET myhash field1
"Hello"
127.0.0.1:6379> HSET myhash field2 "Hi" field3 "World"
(integer) 2
127.0.0.1:6379> HGET myhash field2
"Hi"
127.0.0.1:6379> HGET myhash field3
"World"
127.0.0.1:6379> HGETALL myhash
1) "field1"
2) "Hello"
3) "field2"
4) "Hi"
5) "field3"
6) "World"

look at her go 😭 two fields added in one call and HGETALL shows the whole little family. main character energy fr fr πŸ‘‘


🌈 SEE ALSO 🌈


πŸ’– that's the whole page bestie, go forth and set some fields πŸ’–

mwah πŸ’‹ this was page HSET(3valkey) from Valkey version 9.0.0, dated 2025-10-21 β€” thanks for reading, ily, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from