# VolatileJournalStorage Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/)

## AppendAsync(ReadOnlySequence&lt;byte&gt;, CancellationToken) {#appendasync-system-buffers-readonlysequence-byte-system-threading-cancellationto-902dc15f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/appendasync-system-buffers-readonlysequence-byte-system-threading-cancellationto-902dc15f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L235-L244)

```csharp
public ValueTask AppendAsync(ReadOnlySequence<byte> segment, CancellationToken cancellationToken)
```

Appends the provided segment to the journal atomically.

### Parameters

- `segment` (`ReadOnlySequence<byte>`): The encoded journal bytes to append. The storage provider must not retain this buffer after the returned task completes.
- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

A `System.Threading.Tasks.ValueTask` representing the operation.

## CreateIfNotExistsAsync(IReadOnlyDictionary&lt;string, string&gt;, CancellationToken) {#createifnotexistsasync-system-collections-generic-ireadonlydictionary-string-str-9c1ec14d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/createifnotexistsasync-system-collections-generic-ireadonlydictionary-string-str-9c1ec14d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L162-L174)

```csharp
public ValueTask<bool> CreateIfNotExistsAsync(IReadOnlyDictionary<string, string>? metadata = null, CancellationToken cancellationToken = default(CancellationToken))
```

Creates this journal storage instance if it does not already exist.

### Parameters

- `metadata` (`IReadOnlyDictionary<string, string>`): Initial caller-owned metadata properties.
- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

`true` if storage was created; otherwise, `false`.

## DeleteAsync(CancellationToken) {#deleteasync-system-threading-cancellationtoken-ff23bffa}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/deleteasync-system-threading-cancellationtoken-ff23bffa/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L265-L271)

```csharp
public ValueTask DeleteAsync(CancellationToken cancellationToken)
```

Deletes the journal atomically.

### Parameters

- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

A `System.Threading.Tasks.ValueTask` representing the operation.

## GetMetadataAsync(CancellationToken) {#getmetadataasync-system-threading-cancellationtoken-2ba703ab}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/getmetadataasync-system-threading-cancellationtoken-2ba703ab/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L178-L183)

```csharp
public ValueTask<IJournalMetadata?> GetMetadataAsync(CancellationToken cancellationToken = default(CancellationToken))
```

Gets metadata for this journal storage instance.

### Parameters

- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

The metadata, or `null` if the storage instance does not exist.

## ReadAsync(IJournalStorageConsumer, CancellationToken) {#readasync-orleans-journaling-ijournalstorageconsumer-system-threading-cancellati-48eea24c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/readasync-orleans-journaling-ijournalstorageconsumer-system-threading-cancellati-48eea24c/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L209-L220)

```csharp
public ValueTask ReadAsync(IJournalStorageConsumer consumer, CancellationToken cancellationToken)
```

Reads all journal data belonging to this instance and sends it to `consumer`.

### Parameters

- `consumer` (`IJournalStorageConsumer`): The consumer of ordered raw journal data. Chunk boundaries are not journal-entry boundaries.
- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

A `System.Threading.Tasks.ValueTask` representing the operation.

## ReplaceAsync(ReadOnlySequence&lt;byte&gt;, CancellationToken) {#replaceasync-system-buffers-readonlysequence-byte-system-threading-cancellationt-391f7718}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/replaceasync-system-buffers-readonlysequence-byte-system-threading-cancellationt-391f7718/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L250-L260)

```csharp
public ValueTask ReplaceAsync(ReadOnlySequence<byte> snapshot, CancellationToken cancellationToken)
```

Replaces the journal with the provided value atomically.

### Parameters

- `snapshot` (`ReadOnlySequence<byte>`): The encoded journal bytes to write. The storage provider must not retain this buffer after the returned task completes.
- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

A `System.Threading.Tasks.ValueTask` representing the operation.

## UpdateMetadataAsync(IReadOnlyDictionary&lt;string, string&gt;, IEnumerable&lt;string&gt;, string?, CancellationToken) {#updatemetadataasync-system-collections-generic-ireadonlydictionary-string-string-e8ee89b2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.volatilejournalstorage/methods/updatemetadataasync-system-collections-generic-ireadonlydictionary-string-string-e8ee89b2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/VolatileJournalStorage.cs#L191-L204)

```csharp
public ValueTask<IJournalMetadata?> UpdateMetadataAsync(IReadOnlyDictionary<string, string>? set = null, IEnumerable<string>? remove = null, string? expectedETag = null, CancellationToken cancellationToken = default(CancellationToken))
```

Conditionally updates caller-owned metadata properties.

### Parameters

- `set` (`IReadOnlyDictionary<string, string>`): Metadata properties to set.
- `remove` (`IEnumerable<string>`): Metadata properties to remove.
- `expectedETag` (`string?`): The expected metadata ETag, or `null` for an unconditional update.
- `cancellationToken` (`CancellationToken`): The cancellation token.

### Returns

The current metadata if the update was applied or made no changes; otherwise, `null`.
