Skip to content

ZGET.F64

Retrieves the value for a key from the ZMap ordered key-value store as an IEEE-754 double-precision floating-point number.

ZGET.F64 <key>

The argument is positional.

ArgumentTypeRequiredDescription
keybytesYesThe key to look up.

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.

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 ZSET using 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 BEGIN has 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.

Argument errors:

Error CodeError messageCause
ERRwrong number of arguments for 'ZGET.F64' commandNot exactly one argument.

Stored value errors:

Error CodeError messageCause
ERRInvalid stored value: expected 8-byte IEEE-754 doubleThe stored value is not exactly 8 bytes.

Read a value set by ZINC.F64:

> ZINC.F64 counter 123.456
OK
> ZGET.F64 counter
(double) 123.456

Read a non-existent key:

> ZGET.F64 nosuchkey
(nil)

Read after multiple increments:

> ZINC.F64 counter 2.5
OK
> ZINC.F64 counter 2.5
OK
> ZINC.F64 counter 2.5
OK
> ZGET.F64 counter
(double) 7.5

Read an invalid (non-8-byte) value:

> ZSET badkey "abc"
OK
> ZGET.F64 badkey
(error) ERR Invalid stored value: expected 8-byte IEEE-754 double