# IJournalStorage Methods

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

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

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournalstorage/methods/appendasync-system-buffers-readonlysequence-byte-system-threading-cancellationto-1b302cf0/)

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

Appends the provided segment to the journal atomically.

### Parameters

- `value` (`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-5f2a01cd}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournalstorage/methods/createifnotexistsasync-system-collections-generic-ireadonlydictionary-string-str-5f2a01cd/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/IJournalStorage.cs#L38)

```csharp
public virtual 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-af8d7c6d}

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

```csharp
public abstract 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-8a9a064d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournalstorage/methods/getmetadataasync-system-threading-cancellationtoken-8a9a064d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/IJournalStorage.cs#L46)

```csharp
public virtual 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-2d52dd2f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournalstorage/methods/readasync-orleans-journaling-ijournalstorageconsumer-system-threading-cancellati-2d52dd2f/)

```csharp
public abstract 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-ddda5902}

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

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

Replaces the journal with the provided value atomically.

### Parameters

- `value` (`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-a93f4a54}

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

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/IJournalStorage.cs#L67)

```csharp
public virtual 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`.
