ZSET.D128
Sets a key to a 128-bit decimal value in the ZMap ordered key-value store.
Syntax
Section titled “Syntax”ZSET.D128 <key> <value>Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
key | bytes | Yes | The key to set. |
value | string | Yes | A decimal number as a string. Accepts plain decimals and scientific notation (e.g., 1.). |
Return Value
Section titled “Return Value”Simple string: OK on success.
Behavior
Section titled “Behavior”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
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”ERR is returned when:
- Invalid decimal: the value is not a parseable decimal string.
Exponent is out of range for Decimal128 encoding ...: The value exceeds the Decimal128 representable range.- Wrong number of arguments or internal failure.
Examples
Section titled “Examples”Set a decimal value:
> ZSET.D128 price 19.99OK
> ZGET.D128 price"19.99"Overwrite an existing value:
> ZSET.D128 price 19.99OK
> ZSET.D128 price 24.99OK
> ZGET.D128 price"24.99"High-precision decimal (34 significant digits):
> ZSET.D128 pi 3.141592653589793238462643383279502OK
> ZGET.D128 pi"3.141592653589793238462643383279502"Invalid string rejection:
> ZSET.D128 price notanumber(error) ERR invalid decimalUse within an explicit transaction:
> BEGINOK
> ZSET.D128 tx-price 42.42OK
> COMMITOK
> ZGET.D128 tx-price"42.42"