ZSET
Sets a key-value pair in the ZMap ordered key-value store.
Syntax
Section titled “Syntax”ZSET <key> <value>Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
key | bytes | Yes | The key to set. |
value | bytes | Yes | The value to associate with the key. |
Return Value
Section titled “Return Value”Simple string: OK on success.
Behavior
Section titled “Behavior”ZSET writes a key-value pair into the ZMap subspace of the session’s current namespace, backed by FoundationDB. Keys
are stored in lexicographic order.
If the key already exists, its value is overwritten silently. There is no duplicate-key error.
The command supports two transaction modes:
- Auto-commit (one-off): When no explicit transaction is active, Kronotop creates a transaction, performs the write, and commits it immediately. This is the default mode.
- Explicit transaction: When a
BEGINhas been issued, the write is staged in the current transaction and only persists whenCOMMITis called.
All data is scoped to the session’s active namespace. The same key in different namespaces refers to different entries.
Errors
Section titled “Errors”| Error Code | Description |
|---|---|
ERR | Wrong number of arguments or internal failure. |
Examples
Section titled “Examples”Set a key-value pair:
> ZSET mykey "Hello"OKOverwrite an existing key:
> ZSET mykey "Hello"OK
> ZSET mykey "World"OK
> ZGET mykey"World"Use within an explicit transaction:
> BEGINOK
> ZSET mykey "Hello"OK
> ZSET anotherkey "World"OK
> COMMITOK