getAndLock method

Future<GetResult> getAndLock(
  1. String key,
  2. Duration lockTime, [
  3. GetAndLockOptions? options
])

Locks a document and retrieves the value of that document at the time it is locked.

Implementation

Future<GetResult> getAndLock(
  String key,
  Duration lockTime, [
  GetAndLockOptions? options,
]) async {
  options ??= const GetAndLockOptions();

  final response = await _connection.getAndLock(
    GetAndLockRequest(
      id: _documentId(key),
      lockTime: lockTime.inSeconds,
      timeout: _kvTimeout(options),
      partition: 0,
      opaque: 0,
    ),
  );

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