HSET
Syntax
HSET key field value [field value ...]
Time 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.
ACL categories: @write, @hash, @fast
Sets the specified fields to their respective values in the hash stored at key.
This command overwrites the values of specified fields that exist in the hash.
If key doesn't exist, a new key holding a hash is created.
Return
Integer reply: The number of fields that were added.
Examples
dragonfly> HSET myhash field1 "Hello"
(integer) 1
dragonfly> HGET myhash field1
"Hello"
dragonfly> HSET myhash field2 "Hi" field3 "World"
(integer) 2
dragonfly> HGET myhash field2
"Hi"
dragonfly> HGET myhash field3
"World"
dragonfly> HGETALL myhash
1) "field1"
2) "Hello"
3) "field2"
4) "Hi"
5) "field3"
6) "World"
Benchmark
Sustained throughput for HSET on a single instance, measured against Redis and Valkey on identical hardware. Higher is better.
| Engine | Throughput | p50 | p99 | p99.9 | Avg Latency |
|---|---|---|---|---|---|
| Dragonfly | 7.99M ops/s | 0.507 ms | 1.985 ms | 7.332 ms | 0.583 ms |
| Valkey | 704.0K ops/s | 6.573 ms | 13.470 ms | 17.760 ms | 6.804 ms |
| Redis | 638.5K ops/s | 6.839 ms | 11.613 ms | 18.655 ms | 7.503 ms |
Methodology
| Hardware | Server: m7g.8xlarge (arm64) · Client: c6gn.8xlarge (arm64) |
| Client | 32 threads, 5 connections, pipeline 30 |
| Dataset | 100M keys, 128B values, uniform key distribution |
| Duration | 300s (10s warmup), 1 trial |
| Measured | 2026-07-28 |
Ran through dfly_bench until throughput stabilized; the reported figure is the median throughput sampled during the run. Harness and raw output: dragonflydb/benchmarking.