#include "tensorstore/kvstore/operations.h"
Future<TimestampedStorageGeneration>
tensorstore::kvstore::Write(const KvStorestore,
                            
std::string_view key,
                            
std::optional<Value> value,
                            
WriteOptions options = {});
Future<TimestampedStorageGeneration>
tensorstore::kvstore::WriteCommitted(const KvStorestore,
                                     
std::string_view key,
                                     
std::optional<Value> value,
                                     
WriteOptions options = {});

Performs an optionally-conditional write.

Atomically updates or deletes the value stored for store.path + key subject to the conditions specified in options.

WriteCommitted behaves the same as Write for non-transactional writes. For transactional writes, the future returned by WriteCommitted becomes ready only once the transaction is committed or aborted, and if the write is successful, contains the actual TimestampedStorageGeneration; in contrast, the future returned by Write becomes ready immediately to reflect the fact that the value can immediately be read back in the context of the transaction.

Parameters:
const KvStore &store

KvStore into which to perform the write operation.

std::string_view key

The key to write or delete, interpreted as a suffix to be appended to store.path.

std::optional<Value> value

The value to write, or std::nullopt to delete.

WriteOptions options = {}

Specifies options for writing.

Returns:

A Future that resolves to the generation corresponding to the new value on success, or to StorageGeneration::Unknown() if the conditions in options are not satisfied.

struct tensorstore::kvstore::WriteGenerationConditions;

Conditions on the existing generation for write operations.

struct tensorstore::kvstore::WriteOptions;

Options for Write.