Documentation
Table of Contents

Method WriteStateAsync

Namespace
IntentSharp.Documents
Assembly
IntentSharp.dll

WriteStateAsync(string, JsonNode, string?, CancellationToken)

Writes a state value. With expectedEtag null the value is created or overwritten; otherwise it is written only when the key's current etag is expectedEtag. Returns the entry as written, with its new etag. To create a value only when the key has none, call TryCreateStateAsync(string, JsonNode, CancellationToken).

public ValueTask<StateEntry> WriteStateAsync(string key, JsonNode value, string? expectedEtag, CancellationToken ct = default)

Parameters

key string

The state key.

value JsonNode

The value to store; the store keeps a copy.

expectedEtag string

The etag the key must have, from an earlier read or write; null to write regardless.

ct CancellationToken

Cancels the call.

Returns

ValueTask<StateEntry>

Exceptions

ArgumentException

key is null or blank.

ArgumentNullException

value is null.

DocumentConflictException

expectedEtag is set and the key's current etag differs, or the key has no value. Nothing was written.

ObjectDisposedException

The store is disposed.

IOException

The state could not be written, or the lock file stayed held by another instance for LockTimeout.

InvalidOperationException

A document validator called it while this store was checking an edit (see the class remarks).