OxL Справочник OxL
РусскийEnglish

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✓ проверяется в 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()
}
Вывод
false false
pub(api) fn reading(mode: Consistency, maxStale: Duration = Duration.ofSeconds(1)) -> Kv

С версии. 1.0.0-beta

Параметры

ИмяТип
modeConsistency
maxStaleDuration = Duration.ofSeconds(1)

Возвращает

Kv

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/kv/kv.oxl:323

См. также