# RedisGrainStorage Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/)

## ClearStateAsync(string, GrainId, IGrainState&lt;T&gt;) {#clearstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-ec9c86e2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/methods/clearstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-ec9c86e2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs#L206-L254)

```csharp
public Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Delete / Clear data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): Copy of last-known state data object for this grain.

### Returns

Completion promise for the Delete operation on the specified grain.

## Dispose {#dispose-f9778335}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/methods/dispose-f9778335/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs#L258-L273)

```csharp
public void Dispose()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

## DisposeAsync {#disposeasync-5fd36e0b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/methods/disposeasync-5fd36e0b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs#L277-L292)

```csharp
public ValueTask DisposeAsync()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

### Returns

A task that represents the asynchronous dispose operation.

## Participate(ISiloLifecycle) {#participate-orleans-runtime-isilolifecycle-69855bc6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/methods/participate-orleans-runtime-isilolifecycle-69855bc6/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs#L64-L66)

```csharp
public void Participate(ISiloLifecycle lifecycle)
```

Adds the provided observer as a participant in the lifecycle.

### Parameters

- `lifecycle` (`ISiloLifecycle`): The observer.

## ReadStateAsync(string, GrainId, IGrainState&lt;T&gt;) {#readstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-018e757d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/methods/readstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-018e757d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs#L93-L127)

```csharp
public Task ReadStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Read data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): State data object to be populated for this grain.

### Returns

Completion promise for the Read operation on the specified grain.

## WriteStateAsync(string, GrainId, IGrainState&lt;T&gt;) {#writestateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-fbb6b4cc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.redis/orleans.persistence.redisgrainstorage/methods/writestateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-fbb6b4cc/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs#L146-L171)

```csharp
public Task WriteStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Write data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): State data object to be written for this grain.

### Returns

Completion promise for the Write operation on the specified grain.
