OxL Reference

method Kv.reading

A handle on the same store whose get and scan use mode (writes and transactions are not affected: they go through the leader). maxStale is read by Stale only (default one second; it is rounded to a whole number of milliseconds, at least 1 ms).

oxl
let fast = kv.reading(.Follower)
let v = fast.get("k")

Example:

oxl✓ checked in CI
use std.kv { Kv, Consistency }
use std.core { Utf8 }
use std.time { Duration }

fn main() io, db {
  let kv = Kv.open("example-reading")!
  kv.put("k", Utf8.encode("v"))!
  let follower = kv.reading(.Follower)
  let stale = kv.reading(.Stale, Duration.ofMillis(200))
  print("{follower.get("k") is none} {stale.get("k") is none}")
  kv.close()
}
Output
false false
pub(api) fn reading(mode: Consistency, maxStale: Duration = Duration.ofSeconds(1)) -> Kv

Since. 1.0.0-beta

Parameters

NameType
modeConsistency
maxStaleDuration = Duration.ofSeconds(1)

Returns

Kv

Effects

none declared (pure unless the body says otherwise)

Defined in: std/kv/kv.oxl:323

See also