put method

  1. @override
Future<int?> put(
  1. String key,
  2. AtNotification value, {
  3. bool skipCommit = false,
})
override

Associates value with key. If a mapping already exists, the old value is replaced.

Returns the commit-log sequence number assigned to this write, or null if no sequence number was produced (when skipCommit is true, or when this backend does not maintain a commit log).

Throws a DataStoreException if the underlying store fails.

Implementation

@override
Future<int?> put(key, value, {bool skipCommit = false}) async {
  if (key.length > maxKeyLengthWithoutCached) {
    throw DataStoreException(
        'key length ${key.length} is greater than $maxKeyLengthWithoutCached chars');
  }
  final wasPresent = await exists(key);
  await _getBox().put(key, value);
  _expiryIndex[key] = _effectiveExpiry(value);
  _changesController.add(wasPresent ? KeyUpdated(key) : KeyAdded(key));
  return null;
}