HSET
Creates or modifies the value of a field in a hash.
Browse all commands · Upstream source documentation
| Reference field | Value |
|---|---|
| Canonical name | HSET |
| Catalog group | Hash commands |
| Upstream since | 2.0.0 — upstream Redis/module version, not an ffkv release |
| Pinned catalog | Redis 8.10.0 |
Syntax
Section titled “Syntax”HSET key field value [field value ...]ffkv behavior and limits
Section titled “ffkv behavior and limits”Hash fields have independent expiration. Counted field forms use FIELDS n; HSETEX counts field/value pairs. Key TTL and field TTL are distinct.
Source: README.md:587–599; tests/bdd/features/hashes.feature.
All requests share the 8 MiB framing/1,024-argument ingress limit; normal RESP replies have 64 MiB wire/logical budgets with bounded nesting/value counts. Management and Lua origins impose smaller budgets. These are not a process RSS cap. Catalog inclusion is not exhaustive option or wire-format parity. See limits and compatibility.
Upstream metadata
Section titled “Upstream metadata”The following fields come from the pinned Redis metadata, not measured ffkv performance or an assertion that ffkv enforces every upstream flag. Running COMMAND INFO/COMMAND DOCS describe the current engine.
Upstream Redis 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.
Upstream arity: -4 (includes the command name; a negative number is a minimum).
Command flags: WRITE, DENYOOM, FAST.
ACL categories: HASH.
Argument structure
Section titled “Argument structure”| Argument | Type | Constraints / metadata |
|---|---|---|
key | key | key_spec_index: 0 |
data | block | multiple |
↳ field | string | Required |
↳ value | string | Required |
Key specifications
Section titled “Key specifications”Upstream key discovery descriptors (indexes are relative to the full command vector):
[ { "flags": [ "RW", "UPDATE" ], "begin_search": { "index": { "pos": 1 } }, "find_keys": { "range": { "lastkey": 0, "step": 1, "limit": 0 } } }]Additional pinned upstream metadata
{ "group": "hash", "since": "2.0.0", "history": [ [ "4.0.0", "Accepts multiple `field` and `value` arguments." ] ]}Metadata source · Local snapshot: src/command_metadata.json, key hset.
BDD coverage and source examples
Section titled “BDD coverage and source examples”These are source observations, not a test run performed by this documentation build. A tag identifies scenario intent; an extracted vector identifies a command invocation, which may intentionally produce an error. Scenarios may require setup, multiple connections, persistence, cluster nodes or native-module fixtures.
- Restore-asking uses the same verified value payload and collision rules —
tests/bdd/features/catalog.feature:212; invocation observed. - Dynamic document deletion denials identify only the rejected document —
tests/bdd/features/client_control_repair.feature:533; invocation observed. - SORT_RO tracks real scalar and hash lookups rather than wildcard patterns —
tests/bdd/features/client_control_repair.feature:571; invocation observed. - Atomic import transfers real typed data and survives destination restart —
tests/bdd/features/cluster.feature:498; invocation observed. - Function and search metadata accompany migrated keys without replacing unrelated catalogs —
tests/bdd/features/cluster.feature:1011; invocation observed. - Copy across databases replaces only when requested and detaches hash values and field deadlines —
tests/bdd/features/generic.feature:5; invocation observed. - Existence counts repeated arguments but deletion counts each removed key once —
tests/bdd/features/generic.feature:129; invocation observed. - Hash serialization preserves binary fields and absolute field expiration independently —
tests/bdd/features/generic.feature:316; invocation observed. - Move respects destination collisions and transfers a hash with its deadline to another database —
tests/bdd/features/generic.feature:768; invocation observed. - Object representation metadata describes a live value and is absent for nonexistent keys —
tests/bdd/features/generic.feature:852; invocation observed. - Sort resolves external hash weights and multiple GET patterns before limiting and storing —
tests/bdd/features/generic.feature:1203; invocation observed. - Type distinguishes built in values and missing keys without inspecting their contents —
tests/bdd/features/generic.feature:1352; invocation observed. - Migration copies into a real target database and removes the source only for a move —
tests/bdd/features/generic.feature:1408; invocation observed. - Hash writes count new binary-safe fields and preserve requested read order —
tests/bdd/features/hashes.feature:4; command tag and invocation observed. - Conditional creation cannot overwrite an existing field —
tests/bdd/features/hashes.feature:49; invocation observed. - Hash field enumeration and byte lengths differ from character counts —
tests/bdd/features/hashes.feature:125; invocation observed. - Deletion counts each existing field only once and removes an empty key —
tests/bdd/features/hashes.feature:165; invocation observed. - Signed integer increments preserve existing field deadlines —
tests/bdd/features/hashes.feature:197; invocation observed. - Floating increments normalize decimals and resolve durable values —
tests/bdd/features/hashes.feature:242; invocation observed. - Scanning supports matching and names-only replies without changing the hash —
tests/bdd/features/hashes.feature:287; invocation observed. - Get-and-delete processes duplicate fields in order and deletes the last-field key —
tests/bdd/features/hashes.feature:319; invocation observed. - Get-with-expiry supports absolute deadlines persistence and immediate expiration —
tests/bdd/features/hashes.feature:343; invocation observed. - Malformed field blocks never consume values —
tests/bdd/features/hashes.feature:404; invocation observed. - All-fields conditions are atomic and keep existing field expirations —
tests/bdd/features/hashes.feature:430; invocation observed. - HEXPIRE reports per-field outcomes and respects expiration conditions —
tests/bdd/features/hashes.feature:486; invocation observed. - HPEXPIRE reports per-field outcomes and respects expiration conditions —
tests/bdd/features/hashes.feature:526; invocation observed. - HEXPIREAT exposes absolute deadlines and independent conditional outcomes —
tests/bdd/features/hashes.feature:566; invocation observed. - HPEXPIREAT exposes absolute deadlines and independent conditional outcomes —
tests/bdd/features/hashes.feature:614; invocation observed. - TTL states distinguish persistent missing and removed expirations —
tests/bdd/features/hashes.feature:662; invocation observed. - Random field count modes and RESP2 values preserve duplicates correctly —
tests/bdd/features/hashes.feature:702; invocation observed. - RESP3 random values are ordered field-value pairs —
tests/bdd/features/hashes.feature:768; invocation observed. - Malformed writes and numeric grammar errors leave the hash unchanged —
tests/bdd/features/hashes.feature:785; command tag and invocation observed. - Hash mutations and field deadlines survive crash recovery —
tests/bdd/features/hashes.feature:852; invocation observed. - Prepared layouts preserve declared field order and replace complete hashes —
tests/bdd/features/hashes.feature:877; invocation observed. - Counted field blocks permit trailing options and keyword field names —
tests/bdd/features/hashes.feature:1323; invocation observed. - Extended-precision float arithmetic avoids double rounding —
tests/bdd/features/hashes.feature:1402; invocation observed. - Zero relative expiry is immediately destructive and duplicate-safe —
tests/bdd/features/hashes.feature:1455; invocation observed. - Expiry conditions may follow counted fields and mixed conditions fail atomically —
tests/bdd/features/hashes.feature:1492; invocation observed. - Random access indexes survive field deletion expiry and reinsertion —
tests/bdd/features/hashes.feature:1564; invocation observed. - Positive random counts return every distinct field at most once —
tests/bdd/features/hashes.feature:1604; invocation observed. - Numeric signed zero bounds share equality without invalid ranges —
tests/bdd/features/search.feature:5; invocation observed. - Empty tag queries follow initial scans updates deletion and rebuild —
tests/bdd/features/search.feature:61; invocation observed. - Initial scans and typed intersections find only eligible documents —
tests/bdd/features/search.feature:113; invocation observed. - Hash mutations remove old postings without losing the source value —
tests/bdd/features/search.feature:137; invocation observed. - Invalid indexed values reject the document but never roll back HSET —
tests/bdd/features/search.feature:161; invocation observed. - Alias creation rebinding and deletion affect metadata only —
tests/bdd/features/search.feature:206; invocation observed. - ALTER validates a full new schema before rescanning existing documents —
tests/bdd/features/search.feature:255; invocation observed. - Dictionaries supplement real document-frequency spelling suggestions —
tests/bdd/features/search.feature:321; invocation observed. - Synonym updates preserve skipped document coverage through recovery —
tests/bdd/features/search.feature:361; invocation observed. - Tags preserve interior spaces and normalize only configured case —
tests/bdd/features/search.feature:406; invocation observed. - DROPINDEX keeps documents unless DD explicitly deletes indexed sources —
tests/bdd/features/search.feature:462; invocation observed. - Ordered transformations feed genuine grouped reducers —
tests/bdd/features/search.feature:511; invocation observed. - Global reducers consume all input rows exactly once —
tests/bdd/features/search.feature:532; invocation observed. - Repeated grouping preserves stage order and sorted distinct records —
tests/bdd/features/search.feature:565; invocation observed. - A cursor advances real pipeline state without duplicate or skipped rows —
tests/bdd/features/search.feature:598; invocation observed. - Deleted cursor handles cannot be reused —
tests/bdd/features/search.feature:637; invocation observed. - Profiling returns the actual query result and measured execution metadata —
tests/bdd/features/search.feature:663; invocation observed. - Each vector algorithm maintains a real index across updates and deletions (Scenario Outline) —
tests/bdd/features/search.feature:693; invocation observed. - Reciprocal-rank fusion combines the union of text and vector branches —
tests/bdd/features/search.feature:726; invocation observed. - Geographic radius and nonrectangular shape predicates use indexed geometry —
tests/bdd/features/search.feature:755; invocation observed. - Phrase fuzzy stemming and highlighting share genuine match positions —
tests/bdd/features/search.feature:816; invocation observed. - Minimum stem length governs indexed words without blocking short query roots —
tests/bdd/features/search.feature:856; invocation observed. - Missing and empty fields remain distinct searchable states —
tests/bdd/features/search.feature:880; invocation observed. - Rename expiration deletion and type replacement do not leave stale postings —
tests/bdd/features/search.feature:904; invocation observed. - Recovery retains intentionally unindexed initial data and metadata namespaces —
tests/bdd/features/search.feature:944; invocation observed. - ACLs authorize prefix namespaces rather than the index name —
tests/bdd/features/search.feature:985; invocation observed. - Invalid query schema and pipeline options fail without document mutation (Scenario Outline) —
tests/bdd/features/search.feature:1027; invocation observed. - COLLECT preserves nested stage-local records across chained grouping —
tests/bdd/features/search.feature:1058; invocation observed. - Expressions compose string arithmetic conditional and UTC date functions —
tests/bdd/features/search.feature:1075; invocation observed. - Search payloads and aggregate LOAD remain binary safe —
tests/bdd/features/search.feature:1092; invocation observed. - Invalid vector blobs do not undo successful document writes —
tests/bdd/features/search.feature:1132; invocation observed. - Suffix dictionaries update when their last posting disappears —
tests/bdd/features/search.feature:1168; invocation observed. - Read-only document grants never authorize DROPINDEX DD deletion —
tests/bdd/features/search.feature:1196; invocation observed. - Matching a literal prefix probe does not authorize a whole index namespace —
tests/bdd/features/search.feature:1225; invocation observed. - Search worker reconfiguration preserves queries and enforces strict timeout prerequisites —
tests/bdd/features/search.feature:1246; invocation observed. - Disposable Lua debugging sees staged search changes without publishing catalog changes —
tests/bdd/features/search.feature:1316; invocation observed. - Swapping database zero reconciles search documents without replacing schemas or aliases —
tests/bdd/features/search.feature:1381; invocation observed.
Extracted command vectors
Section titled “Extracted command vectors”The following JSON arrays are the test harness’s argument vectors, not shell commands. Numeric arguments are converted by the harness; objects of the form {"base64":"…"} represent decoded binary bytes, not a literal JSON command argument. Preserve scenario setup and connection ordering. See the CLI guide for shell quoting and binary stdin. No reply is invented or inferred.
Hash writes count new binary-safe fields and preserve requested read order — tests/bdd/features/hashes.feature:15 (I execute:)
[ "HSET", "h", "a", "3"]Next source assertion: the reply equals:
0Random access indexes survive field deletion expiry and reinsertion — tests/bdd/features/hashes.feature:1578 (I execute:)
[ "HSET", "h", "b", "second"]Next source assertion: the reply equals:
1Migration copies into a real target database and removes the source only for a move — tests/bdd/features/generic.feature:1452 (I execute:)
[ "HSET", "transfer", "field", "changed"]Next source assertion: the reply equals:
0