Skip to content

ZSET.D128

Sets a key to a 128-bit decimal value in the ZMap ordered key-value store.

ZSET.D128 <key> <value>

Both arguments are positional.

ArgumentTypeRequiredDescription
keybytesYesThe key to set.
valuestringYesA decimal number as a string. Accepts plain decimals and scientific notation (e.g., 1.5E+10).

Simple string: OK on success.

ZSET.D128 writes a typed 128-bit decimal value for a key in the ZMap subspace of the session’s current namespace. The input string is parsed as a BigDecimal and then converted to IEEE-754 decimal128 (BID encoding), stored as 16 bytes in little-endian format, the same encoding used by ZINC.D128 and read by ZGET.D128.

Decimal128 provides 34 significant digits of precision, making it suitable for financial calculations and other use cases where exact decimal representation matters.

If the key already exists, its value is overwritten silently.

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 BEGIN has been issued, the write is staged in the current transaction and only persists when COMMIT is called.

All data is scoped to the session’s active namespace. The same key in different namespaces refers to different entries.

Argument errors:

Error CodeError messageCause
ERRwrong number of arguments for 'ZSET.D128' command-
ERRinvalid decimal-
ERRExponent is out of range for Decimal128 encoding of <value>-

Set a decimal value:

> ZSET.D128 price 19.99
OK
> ZGET.D128 price
"19.99"

Overwrite an existing value:

> ZSET.D128 price 19.99
OK
> ZSET.D128 price 24.99
OK
> ZGET.D128 price
"24.99"

High-precision decimal (34 significant digits):

> ZSET.D128 pi 3.141592653589793238462643383279502
OK
> ZGET.D128 pi
"3.141592653589793238462643383279502"

Invalid string rejection:

> ZSET.D128 price notanumber
(error) ERR invalid decimal

Use within an explicit transaction:

> BEGIN
OK
> ZSET.D128 tx-price 42.42
OK
> COMMIT
OK
> ZGET.D128 tx-price
"42.42"