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).
let fast = kv.reading(.Follower)
let v = fast.get("k")Example:
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)) -> KvSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
mode | Consistency |
maxStale | Duration = Duration.ofSeconds(1) |
Returns
Effects
none declared (pure unless the body says otherwise)
Defined in: std/kv/kv.oxl:323