HSET(3valkey)
π 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 π
hdel(3valkey)hexists(3valkey)hexpire(3valkey)hexpireat(3valkey)hexpiretime(3valkey)hget(3valkey)hgetall(3valkey)hgetex(3valkey)hincrby(3valkey)hincrbyfloat(3valkey)hkeys(3valkey)hlen(3valkey)hmget(3valkey)hmset(3valkey)hpersist(3valkey)hpexpire(3valkey)hpexpireat(3valkey)hpexpiretime(3valkey)hpttl(3valkey)hrandfield(3valkey)hscan(3valkey)hsetex(3valkey)hsetnx(3valkey)hstrlen(3valkey)httl(3valkey)hvals(3valkey)
π 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
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms