putSync method

void putSync(
  1. Uint8List key,
  2. Bytes document
)

Inserts or replaces key with the encoded document.

Inside a transaction the write is buffered and applied at commit.

Implementation

void putSync(Uint8List key, Bytes document) {
  _checkWritable();
  _checkOpen();
  final bytes = document.asUint8List();
  if (_txOps != null) {
    _record(WalOp.put(key, Uint8List.fromList(bytes)));
    return;
  }
  _wal.appendPutSync(key, bytes);
  final ref = _arena.append(bytes);
  _memtable.put(key, ref.chunk, ref.offset, ref.length);
  _afterWrite();
}