Skip to content

ZDEL

Deletes a key from the ZMap ordered key-value store.

ZDEL <key> [NAMESPACE <path>]

key is positional. NAMESPACE is a keyword argument and comes after it.

ArgumentTypeRequiredDescription
keybytesYesThe key to delete.
NAMESPACEstringNoRun this command in the given namespace instead of the session’s current one. The namespace must exist. The session’s current namespace does not change.

Simple string: OK on success.

ZDEL removes a key and its associated value from the ZMap subspace of the session’s current namespace, backed by FoundationDB.

The operation is idempotent: deleting a non-existent key returns OK without raising an error.

The command supports two transaction modes:

  • Auto-commit (one-off): When no explicit transaction is active, Kronotop creates a transaction, performs the delete, and commits it immediately. This is the default mode.
  • Explicit transaction: When a BEGIN has been issued, the delete is staged in the current transaction and only takes effect when COMMIT is called.

All data is scoped to a namespace: the session’s active one, or the one given with NAMESPACE. The same key in different namespaces refers to different entries.

Argument errors:

Error CodeError messageCause
ERRwrong number of arguments for 'ZDEL' command-
ERRUnknown '<keyword>' argument-
ERRNAMESPACE argument must be followed by a namespace-

Namespace errors:

Error CodeError messageCause
NOSUCHNAMESPACENo such namespace: '<path>'-
NAMESPACEBEINGREMOVEDNamespace '<path>' is being removed-

Delete an existing key:

> ZSET mykey "Hello"
OK
> ZDEL mykey
OK
> ZGET mykey
(nil)

Delete a non-existent key:

> ZDEL nosuchkey
OK

Use within an explicit transaction:

> ZSET mykey "Hello"
OK
> BEGIN
OK
> ZDEL mykey
OK
> COMMIT
OK
> ZGET mykey
(nil)