keepSynced function

void keepSynced(
  1. String path,
  2. bool keep, {
  3. DbQuery? query,
  4. String? app,
})

Keeps path in sync with no listener attached, so a later read is served from cache rather than the network.

Returns as soon as the SDK has taken the instruction; there is nothing to wait for.

Implementation

void keepSynced(String path, bool keep, {DbQuery? query, String? app}) {
  final encoded = (query ?? const DbQuery())._encode();
  final p = path.toNativeUtf8();
  final buf = calloc<Uint8>(encoded.isEmpty ? 1 : encoded.length);
  if (encoded.isNotEmpty) {
    buf.asTypedList(encoded.length).setAll(0, encoded);
  }
  try {
    final rc = _onApp(
      app,
      (a) => fdbDbKeepSynced(a, p.cast(), buf, encoded.length, keep ? 1 : 0),
    );
    if (rc != 0) throw _refuse(rc, 'keepSynced', app);
  } finally {
    calloc
      ..free(p)
      ..free(buf);
  }
}