SET
Sets the string value of a key, ignoring its type. The key is created if it doesn’t exist.
Browse all commands · Upstream source documentation
| Reference field | Value |
|---|---|
| Canonical name | SET |
| Catalog group | String commands |
| Upstream since | 1.0.0 — upstream Redis/module version, not an ffkv release |
| Pinned catalog | Redis 8.10.0 |
Syntax
Section titled “Syntax”SET key value [NX | XX | IFEQ ifeq-value | IFNE ifne-value | IFDEQ ifdeq-digest | IFDNE ifdne-digest] [GET] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]ffkv behavior and limits
Section titled “ffkv behavior and limits”Keys and values are binary-safe bytes. Conditional SET and DELEX comparisons use the stored bytes; DIGEST uses XXH3, not a cryptographic digest.
Source: README.md:571–585; src/engine/strings.rs; tests/bdd/features/strings.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)
Upstream arity: -3 (includes the command name; a negative number is a minimum).
Command flags: WRITE, DENYOOM.
ACL categories: STRING.
Argument structure
Section titled “Argument structure”| Argument | Type | Constraints / metadata |
|---|---|---|
key | key | key_spec_index: 0 |
value | string | Required |
condition | oneof | optional; since: 2.6.12 |
↳ nx | pure-token | token: NX |
↳ xx | pure-token | token: XX |
↳ ifeq-value | string | token: IFEQ; since: 8.4.0 |
↳ ifne-value | string | token: IFNE; since: 8.4.0 |
↳ ifdeq-digest | string | token: IFDEQ; since: 8.4.0 |
↳ ifdne-digest | string | token: IFDNE; since: 8.4.0 |
get | pure-token | optional; token: GET; since: 6.2.0 |
expiration | oneof | optional |
↳ seconds | integer | token: EX; since: 2.6.12 |
↳ milliseconds | integer | token: PX; since: 2.6.12 |
↳ unix-time-seconds | unix-time | token: EXAT; since: 6.2.0 |
↳ unix-time-milliseconds | unix-time | token: PXAT; since: 6.2.0 |
↳ keepttl | pure-token | token: KEEPTTL; since: 6.0.0 |
Key specifications
Section titled “Key specifications”Upstream key discovery descriptors (indexes are relative to the full command vector):
[ { "notes": "RW and ACCESS due to the optional `GET` argument", "flags": [ "RW", "ACCESS", "UPDATE", "VARIABLE_FLAGS" ], "begin_search": { "index": { "pos": 1 } }, "find_keys": { "range": { "lastkey": 0, "step": 1, "limit": 0 } } }]Additional pinned upstream metadata
{ "group": "string", "since": "1.0.0", "history": [ [ "2.6.12", "Added the `EX`, `PX`, `NX` and `XX` options." ], [ "6.0.0", "Added the `KEEPTTL` option." ], [ "6.2.0", "Added the `GET`, `EXAT` and `PXAT` option." ], [ "7.0.0", "Allowed the `NX` and `GET` options to be used together." ], [ "8.4.0", "Added 'IFEQ', 'IFNE', 'IFDEQ', 'IFDNE' options." ] ]}Metadata source · Local snapshot: src/command_metadata.json, key set.
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.
- SETBIT rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:466; invocation observed. - GETBIT rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:495; invocation observed. - BITCOUNT rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:524; invocation observed. - BITPOS rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:553; invocation observed. - BITFIELD rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:582; invocation observed. - BITFIELD_RO rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:611; invocation observed. - BITOP rejects non-string inputs without mutation —
tests/bdd/features/bitmaps.feature:640; invocation observed. - Database-local flush never removes another database —
tests/bdd/features/catalog.feature:92; invocation observed. - Swapping logical databases preserves values TTLs and recovery —
tests/bdd/features/catalog.feature:170; invocation observed. - TIMEOUT unblocking preserves acknowledgments already received from a replica (Scenario Outline) —
tests/bdd/features/client_control_repair.feature:129; invocation observed. - Disposable debugging restores an absent cross-database destination (Scenario Outline) —
tests/bdd/features/client_control_repair.feature:247; invocation observed. - ACL LOG records only the rejected command, key or channel (Scenario Outline) —
tests/bdd/features/client_control_repair.feature:344; invocation observed. - SORT_RO tracks real scalar and hash lookups rather than wildcard patterns —
tests/bdd/features/client_control_repair.feature:571; invocation observed. - A denied actual SORT lookup logs the resource and leaves STORE unchanged —
tests/bdd/features/client_control_repair.feature:621; invocation observed. - Slot list updates validate the whole request before mutating —
tests/bdd/features/cluster.feature:132; invocation observed. - Inclusive range endpoints and overlapping batches are atomic —
tests/bdd/features/cluster.feature:188; invocation observed. - Cluster attachment uses real native replication and both replica spellings —
tests/bdd/features/cluster.feature:283; invocation observed. - Read routing permission is connection-local and never permits replica writes —
tests/bdd/features/cluster.feature:322; invocation observed. - Legacy importing grants ASKING for exactly one command on one connection —
tests/bdd/features/cluster.feature:379; invocation observed. - A mixed-present multi-key migration request returns TRYAGAIN without mutation —
tests/bdd/features/cluster.feature:460; invocation observed. - Coordinated replica promotion observes the processed-offset barrier —
tests/bdd/features/cluster.feature:647; invocation observed. - Flushing assignments rejects a nonempty database and persists an empty release —
tests/bdd/features/cluster.feature:753; invocation observed. - Slot statistics use actual key counts with stable ordering and strict filters —
tests/bdd/features/cluster.feature:871; invocation observed. - Enabled accounting records actual request CPU memory and network work —
tests/bdd/features/cluster.feature:918; invocation observed. - Function and search metadata accompany migrated keys without replacing unrelated catalogs —
tests/bdd/features/cluster.feature:1011; invocation observed. - Live resolved mutations replay list changes deletion and absolute expiry exactly once —
tests/bdd/features/cluster.feature:1109; invocation observed. - Dynamic Lua and function keys cannot diverge from their authoritative cluster owner —
tests/bdd/features/cluster.feature:1279; invocation observed. - Dynamic script admission shares importing and migrating key visibility —
tests/bdd/features/cluster.feature:1379; invocation observed. - Database selection persists per connection without leaking writes to another database —
tests/bdd/features/connections.feature:195; invocation observed. - WRITE pause delays a real mutation but permits reads and an explicit unpause —
tests/bdd/features/connections.feature:304; invocation observed. - OFF suppresses wire replies while executing commands and SKIP affects exactly the next reply —
tests/bdd/features/connections.feature:399; invocation observed. - RESP3 tracking invalidates stale cached values and subsequent reads see new values —
tests/bdd/features/connections.feature:445; invocation observed. - RESP2 redirects invalidations only to the requested persistent subscriber —
tests/bdd/features/connections.feature:495; invocation observed. - OPTIN tracks only the next opted-in read and reports the active tracking flags —
tests/bdd/features/connections.feature:550; invocation observed. - OPTOUT can skip a read and NOLOOP suppresses only the originating writer —
tests/bdd/features/connections.feature:605; invocation observed. - Broadcast prefixes filter writes without requiring reads and flush clears the entire cache —
tests/bdd/features/connections.feature:656; invocation observed. - RESET clears subscriptions, database, names, protocol and tracking without closing the connection —
tests/bdd/features/connections.feature:686; invocation observed. - Expiration invalidates tracked values instead of leaving an expired cache entry —
tests/bdd/features/connections.feature:811; invocation observed. - Tracking shares Redis key names across databases and FLUSHDB invalidates cached results —
tests/bdd/features/connections.feature:849; invocation observed. - Opting in before MULTI tracks all reads in that transaction —
tests/bdd/features/connections.feature:912; 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. - Dump and restore round trip binary values without copying the source key deadline —
tests/bdd/features/generic.feature:182; invocation observed. - Invalid serialized data cannot replace a live value or its deadline —
tests/bdd/features/generic.feature:256; invocation observed. - Relative seconds deadlines honor NX XX GT LT and persistence transitions —
tests/bdd/features/generic.feature:377; invocation observed. - Millisecond expiration conditions preserve live data until an immediate deadline —
tests/bdd/features/generic.feature:515; invocation observed. - Absolute deadlines report exact units and conditionally replace deadlines —
tests/bdd/features/generic.feature:616; invocation observed. - Key patterns support character classes wildcards and escaped metacharacters —
tests/bdd/features/generic.feature:728; 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. - Touch refreshes actual restored idle metadata without changing values or deadlines —
tests/bdd/features/generic.feature:905; invocation observed. - Actual reads advance restored access frequency metadata —
tests/bdd/features/generic.feature:965; invocation observed. - Random key returns the only live key and becomes null after deletion —
tests/bdd/features/generic.feature:1012; invocation observed. - Rename overwrites the destination and preserves the source collection and expiration —
tests/bdd/features/generic.feature:1042; invocation observed. - Conditional rename retains both keys on collision and moves only to an absent destination —
tests/bdd/features/generic.feature:1103; invocation observed. - Sort resolves external hash weights and multiple GET patterns before limiting and storing —
tests/bdd/features/generic.feature:1203; invocation observed. - Read only sorting resolves external keys and leaves an expiring set unchanged —
tests/bdd/features/generic.feature:1304; invocation observed. - Type distinguishes built in values and missing keys without inspecting their contents —
tests/bdd/features/generic.feature:1352; invocation observed. - Waiting for an unavailable replica reports zero without losing the preceding write —
tests/bdd/features/generic.feature:1499; invocation observed. - Waiting for local durability acknowledges the preceding write without replicas —
tests/bdd/features/generic.feature:1523; invocation observed. - Box search and stored distance scores replace a destination with selected members —
tests/bdd/features/geo.feature:125; invocation observed. - Hash operations reject incompatible key types —
tests/bdd/features/hashes.feature:816; invocation observed. - Non-hash target type takes precedence over missing definitions —
tests/bdd/features/hashes.feature:1042; invocation observed. - Existing type errors precede malformed field and expiry options —
tests/bdd/features/hashes.feature:1376; invocation observed. - Sparse decoding and dense conversion expose real representation —
tests/bdd/features/hyperloglog.feature:161; invocation observed. - Seeded register and estimator diagnostics preserve database keys —
tests/bdd/features/hyperloglog.feature:257; invocation observed. - PFADD rejects invalid HYLL without mutating existing values —
tests/bdd/features/hyperloglog.feature:294; invocation observed. - PFCOUNT rejects invalid HYLL without mutating existing values —
tests/bdd/features/hyperloglog.feature:323; invocation observed. - PFMERGE rejects invalid HYLL without mutating existing values —
tests/bdd/features/hyperloglog.feature:352; invocation observed. - PFDEBUG rejects invalid HYLL without mutating existing values —
tests/bdd/features/hyperloglog.feature:381; invocation observed. - Malformed sparse runs are rejected before cache or register access —
tests/bdd/features/hyperloglog.feature:410; invocation observed. - Multi-pop honors key order, duplicates, direction, and the chosen key only —
tests/bdd/features/lists.feature:373; invocation observed. - Destination type errors cannot consume the source (Scenario Outline) —
tests/bdd/features/lists.feature:494; invocation observed. - Blocking single pops choose the first available key and traverse its selected end (Scenario Outline) —
tests/bdd/features/lists.feature:644; invocation observed. - List commands reject incompatible source values without replacing them (Scenario Outline) —
tests/bdd/features/lists.feature:1047; invocation observed. - RESP3 subscription pushes do not prevent ordinary commands on the same connection —
tests/bdd/features/pubsub.feature:230; invocation observed. - Initial synchronization replaces stale data and streams later writes —
tests/bdd/features/replication.feature:7; invocation observed. - Explicit promotion retains data and accepts new writes (Scenario Outline) —
tests/bdd/features/replication.feature:49; invocation observed. - The catalogued legacy spelling starts real followership —
tests/bdd/features/replication.feature:89; invocation observed. - Reconnection requests exactly the missing bytes without another snapshot —
tests/bdd/features/replication.feature:109; invocation observed. - Legacy synchronization consumes real RDB then live RESP effects —
tests/bdd/features/replication.feature:148; invocation observed. - Processed ACK does not pretend the replica has fsynced the write —
tests/bdd/features/replication.feature:178; invocation observed. - Wait uses this connection’s watermark rather than another writer’s offset —
tests/bdd/features/replication.feature:217; invocation observed. - Disconnected replicas are not counted and replicas reject wait commands —
tests/bdd/features/replication.feature:263; invocation observed. - A coordinated standalone handoff preserves writes and changes both roles —
tests/bdd/features/replication.feature:298; invocation observed. - Timeout and explicit abort remove the write pause without promoting a stale replica —
tests/bdd/features/replication.feature:324; invocation observed. - Explicit forced handoff can promote an owned target after the catch-up deadline —
tests/bdd/features/replication.feature:403; invocation observed. - Disabled AOF and impossible local thresholds fail without changing data —
tests/bdd/features/replication.feature:434; invocation observed. - Full polling image replacement retains local command registry ownership —
tests/bdd/features/replication.feature:460; invocation observed. - Readonly scripts reject writes even through protected calls —
tests/bdd/features/scripting.feature:76; invocation observed. - Rename expiration deletion and type replacement do not leave stale postings —
tests/bdd/features/search.feature:904; invocation observed. - Swapping database zero reconciles search documents without replacing schemas or aliases —
tests/bdd/features/search.feature:1381; invocation observed. - Histogram calls describe actual commands and reset independently of dataset —
tests/bdd/features/server.feature:57; invocation observed. - A synchronous save creates a recoverable current dataset —
tests/bdd/features/server.feature:98; invocation observed. - Background save completes with real persistence status —
tests/bdd/features/server.feature:120; invocation observed. - Rewritten journal preserves live values and deletes after restart —
tests/bdd/features/server.feature:142; invocation observed. - Sealed backup restores the seal boundary including incremental writes —
tests/bdd/features/server.feature:164; invocation observed. - Aborting an unsealed backup releases it for a new complete lifecycle —
tests/bdd/features/server.feature:206; invocation observed. - Hotkey network tracking measures requests and preserves stopped results until reset —
tests/bdd/features/server.feature:263; invocation observed. - Memory diagnostics account for live data without inventing allocator internals —
tests/bdd/features/server.feature:313; invocation observed. - Slow log contains actual command arguments and reset removes them —
tests/bdd/features/server.feature:412; invocation observed. - Monitor emits actual failed requests but redacts credential arguments —
tests/bdd/features/server.feature:449; invocation observed. - Saved shutdown exits and persists the dataset —
tests/bdd/features/server.feature:511; invocation observed. - Native key metadata enforces ACL key patterns and nested Call permissions —
tests/bdd/features/server.feature:874; invocation observed. - Existing authenticated sessions observe incremental ACL changes —
tests/bdd/features/server.feature:991; invocation observed. - Selectors expose their real rules and cannot combine permissions across selectors —
tests/bdd/features/server.feature:1136; invocation observed. - Read and write key patterns independently constrain the same command grant —
tests/bdd/features/server.feature:1179; invocation observed. - Saved ACL rules reload atomically and survive a server restart —
tests/bdd/features/server.feature:1385; invocation observed. - Moves preserve the source on wrongtype and handle same-key aliases —
tests/bdd/features/sets.feature:507; invocation observed. - SADD validates every source without replacing the destination —
tests/bdd/features/sets.feature:676; invocation observed. - SCARD validates every source without replacing the destination —
tests/bdd/features/sets.feature:705; invocation observed. - SDIFF validates every source without replacing the destination —
tests/bdd/features/sets.feature:734; invocation observed. - SDIFFCARD validates every source without replacing the destination —
tests/bdd/features/sets.feature:763; invocation observed. - SDIFFSTORE validates every source without replacing the destination —
tests/bdd/features/sets.feature:792; invocation observed. - SINTER validates every source without replacing the destination —
tests/bdd/features/sets.feature:821; invocation observed. - SINTERCARD validates every source without replacing the destination —
tests/bdd/features/sets.feature:850; invocation observed. - SINTERSTORE validates every source without replacing the destination —
tests/bdd/features/sets.feature:879; invocation observed. - SISMEMBER validates every source without replacing the destination —
tests/bdd/features/sets.feature:908; invocation observed. - SMEMBERS validates every source without replacing the destination —
tests/bdd/features/sets.feature:937; invocation observed. - SMISMEMBER validates every source without replacing the destination —
tests/bdd/features/sets.feature:966; invocation observed. - SPOP validates every source without replacing the destination —
tests/bdd/features/sets.feature:995; invocation observed. - SRANDMEMBER validates every source without replacing the destination —
tests/bdd/features/sets.feature:1024; invocation observed. - SREM validates every source without replacing the destination —
tests/bdd/features/sets.feature:1053; invocation observed. - SSCAN validates every source without replacing the destination —
tests/bdd/features/sets.feature:1082; invocation observed. - SUNION validates every source without replacing the destination —
tests/bdd/features/sets.feature:1111; invocation observed. - SUNIONCARD validates every source without replacing the destination —
tests/bdd/features/sets.feature:1140; invocation observed. - SUNIONSTORE validates every source without replacing the destination —
tests/bdd/features/sets.feature:1169; invocation observed. - Invalid store options and source types do not destroy destination —
tests/bdd/features/sorted_sets.feature:975; invocation observed. - Only union and intersection accept regular set inputs —
tests/bdd/features/sorted_sets.feature:1276; invocation observed. - Value comparisons are atomic and failed SET GET returns the old value —
tests/bdd/features/strings.feature:5; command tag and invocation observed. - XXH3 digest matches the published vector and accepts uppercase comparisons —
tests/bdd/features/strings.feature:67; invocation observed. - Conditional deletion cannot remove a changed value —
tests/bdd/features/strings.feature:117; invocation observed. - Decrement uses zero for missing keys and rejects overflow —
tests/bdd/features/strings.feature:209; invocation observed. - Floating increments retain extended precision and TTL —
tests/bdd/features/strings.feature:299; invocation observed. - Bounded increments reject without changing expiration then saturate —
tests/bdd/features/strings.feature:344; invocation observed. - Read and delete removes both value and expiration —
tests/bdd/features/strings.feature:413; invocation observed. - Getex preserves or changes expiration without changing bytes —
tests/bdd/features/strings.feature:442; invocation observed. - Range aliases use inclusive byte indexes and negative offsets —
tests/bdd/features/strings.feature:495; invocation observed. - Getset returns previous bytes and discards expiration —
tests/bdd/features/strings.feature:535; invocation observed. - Counted multi set evaluates NX atomically and shares one expiration —
tests/bdd/features/strings.feature:665; invocation observed. - Sparse writes zero fill holes and retain TTL —
tests/bdd/features/strings.feature:891; invocation observed. - Value comparisons are binary safe and digest equality can delete a key —
tests/bdd/features/strings.feature:952; command tag and invocation observed. - Duplicate options and unrepresentable saturated delta do not mutate —
tests/bdd/features/strings.feature:1001; invocation observed. - An applied bounded increment invalidates a watching transaction —
tests/bdd/features/strings.feature:1092; invocation observed. - String type errors never destroy a collection (Scenario Outline) —
tests/bdd/features/strings.feature:1139; command tag and invocation observed. - Queued writes remain invisible until EXEC and commit in order —
tests/bdd/features/transactions.feature:5; invocation observed. - A competing write aborts WATCH without applying queued changes —
tests/bdd/features/transactions.feature:61; invocation observed. - UNWATCH permits a later transaction after the watched value changes —
tests/bdd/features/transactions.feature:113; invocation observed. - DISCARD removes the queue and watches but not committed values —
tests/bdd/features/transactions.feature:168; invocation observed. - Invalid queued arity aborts the entire transaction without mutation —
tests/bdd/features/transactions.feature:247; invocation observed. - Invalid counted script keys fail during EXEC without discarding adjacent writes (Scenario Outline) —
tests/bdd/features/transactions.feature:289; invocation observed. - Invalid script arity still poisons the transaction at queue admission —
tests/bdd/features/transactions.feature:337; invocation observed. - A transactional statistics reset clears real prior observations without clearing data —
tests/bdd/features/transactions_runtime.feature:91; invocation observed. - A background save scheduled by EXEC runs after its inherited pause is released —
tests/bdd/features/transactions_runtime.feature:140; invocation observed. - Memory usage inside EXEC observes the database selected by a preceding queued command —
tests/bdd/features/transactions_runtime.feature:169; invocation observed. - Memory statistics distinguish allocated bytes from actual live keys across databases —
tests/bdd/features/transactions_runtime.feature:211; invocation observed. - Queue admission checks command ACLs even when script key counts are malformed —
tests/bdd/features/transactions_runtime.feature:271; invocation observed. - Script key ACLs are checked at queue admission and rechecked during execution —
tests/bdd/features/transactions_runtime.feature:314; 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.
A competing write aborts WATCH without applying queued changes — tests/bdd/features/transactions.feature:75 (client “seller” executes:)
[ "SET", "stock", "0"]Next source assertion: the reply equals:
"OK"UNWATCH permits a later transaction after the watched value changes — tests/bdd/features/transactions.feature:135 (client “seller” executes:)
[ "SET", "stock", "2"]Next source assertion: the reply equals:
"OK"Value comparisons are atomic and failed SET GET returns the old value — tests/bdd/features/strings.feature:7 (I execute:)
[ "SET", "state", "old"]Next source assertion: the reply equals:
"OK"