ZGET.F64
Retrieves the value for a key from the ZMap ordered key-value store as an IEEE-754 double-precision floating-point number.
Syntax
Section titled “Syntax”ZGET.F64 <key>Arguments
Section titled “Arguments”The argument is positional.
| Argument | Type | Required | Description |
|---|---|---|---|
key | bytes | Yes | The key to look up. |
Return Value
Section titled “Return Value”Double: the stored value decoded as an IEEE-754 double, or nil if the key does not exist.
RESP2 has no double type. On a RESP2 connection you get a bulk string of 8 bytes. These bytes are the IEEE-754 big-endian form of the number, not its text form. Decode them as a big-endian double. A missing key gives you a bulk string with a length of -1. See Protocol Versions.
Behavior
Section titled “Behavior”ZGET.F64 reads the value for a given key from the ZMap subspace of the session’s current namespace and interprets it
as an IEEE-754 double-precision floating-point number. It is the typed read companion to ZINC.F64. While ZGET
returns raw bytes, ZGET.F64 decodes the stored 8-byte little-endian value and returns it as a double type in the RESP3
protocol.
- If the key does not exist, the command returns
nil. - If the stored value is not exactly 8 bytes, the command returns an error. This can happen when a key was written with
ZSETusing a value that is not a valid 8-byte double encoding.
The command supports two transaction modes:
- Auto-commit (one-off): When no explicit transaction is active, Kronotop creates a transaction, performs the read, and commits it immediately. This is the default mode.
- Explicit transaction: When a
BEGINhas been issued, the read is performed within the current transaction.
ZGET.F64 also supports snapshot reads. When snapshot mode is enabled on the session, the read does not conflict
with concurrent writes, allowing higher throughput for read-heavy workloads.
All data is scoped to the session’s active namespace. The same key in different namespaces refers to different entries.
Errors
Section titled “Errors”Argument errors:
| Error Code | Error message | Cause |
|---|---|---|
ERR | wrong number of arguments for 'ZGET. | Not exactly one argument. |
Stored value errors:
| Error Code | Error message | Cause |
|---|---|---|
ERR | Invalid stored value: expected 8-byte IEEE-754 double | The stored value is not exactly 8 bytes. |
Examples
Section titled “Examples”Read a value set by ZINC.F64:
> ZINC.F64 counter 123.456OK
> ZGET.F64 counter(double) 123.456Read a non-existent key:
> ZGET.F64 nosuchkey(nil)Read after multiple increments:
> ZINC.F64 counter 2.5OK
> ZINC.F64 counter 2.5OK
> ZINC.F64 counter 2.5OK
> ZGET.F64 counter(double) 7.5Read an invalid (non-8-byte) value:
> ZSET badkey "abc"OK
> ZGET.F64 badkey(error) ERR Invalid stored value: expected 8-byte IEEE-754 double