getAndTouch method

Future<GetResult> getAndTouch(
  1. String key,
  2. Duration expiry, [
  3. GetAnyReplicaOptions? options
])

Retrieves the value of the document and simultaneously updates the expiry time for the same document.

Implementation

Future<GetResult> getAndTouch(
  String key,
  Duration expiry, [
  GetAnyReplicaOptions? options,
]) async {
  options ??= const GetAnyReplicaOptions();

  final response = await _connection.getAndTouch(
    GetAndTouchRequest(
      id: _documentId(key),
      expiry: expiry.inSeconds,
      timeout: _kvTimeout(options),
      partition: 0,
      opaque: 0,
    ),
  );

  return GetResult(
    content: _decodeDocument(options, response.flags, response.value),
    cas: response.cas,
  );
}