update<T extends Object> abstract method

  1. @experimental
Future<void> update<T extends Object>({
  1. required Key key,
  2. required Decoder<T?> decoder,
  3. required Transformer<T?> transformer,
  4. required Encoder<T?> encoder,
  5. Options? options,
})

Read–modify–write.

Updates the data transactionally in an atomic read-modify-write operation. All operations are serialized, and the transformer can perform asynchronous computations such as RPCs, database queries, API calls, etc.

The future completes when the data has been persisted durably to disk. If the transform or write to disk fails, the transaction is aborted and the error is rethrown.

When calling this, logic will be executed in the following order:

  • Read raw value by key, then decode it with decoder.
  • Transform the decoded value with transformer.
  • Encode the transformed value with encoder.
  • Finally, save encoded value to persistent storage.

Implementation

@experimental
Future<void> update<T extends Object>({
  required Key key,
  required Decoder<T?> decoder,
  required Transformer<T?> transformer,
  required Encoder<T?> encoder,
  Options? options,
});