put method

  1. @override
Uint8List? put(
  1. Uint8List key,
  2. Uint8List value
)
override

Add a key, value pair to the underlying store, overwriting any existing values. Returns the old value if one existed.

put(utf8.encode('foo',utf8.encode('bar');
put(utf8.encode('foo',utf8.encode('baz'); // returns 'bar'
get(utf8.encode('foo'); // returns 'baz'

Implementation

@override
Uint8List? put(Uint8List key, Uint8List value) {
  final record = _recordPool.put(key, value, true) as RecordBlock;
  if (record.isNew) {
    _header.numBytes += record.size;
    _header.numRecords += 1;
  } else {
    _header.numBytes += record.value.length - value.length;
  }
  if (_flush) flush();
  return record.value;
}