Microsoft.Orleans.Persistence.Redis 9.2.0-preview3
Microsoft Orleans Persistence for Redis
Introduction
Microsoft Orleans Persistence for Redis provides grain persistence for Microsoft Orleans using Redis. This allows your grains to persist their state in Redis and reload it when they are reactivated, leveraging Redis's in-memory data store for fast access.
Getting Started
To use this package, install it via NuGet:
dotnet add package Microsoft.Orleans.Persistence.Redis
Example - Configuring Redis Persistence
using Microsoft.Extensions.Hosting;
using Orleans.Configuration;
using Orleans.Hosting;
var builder = Host.CreateApplicationBuilder(args)
.UseOrleans(siloBuilder =>
{
siloBuilder
.UseLocalhostClustering()
// Configure Redis as grain storage
.AddRedisGrainStorage(
name: "redisStore",
configureOptions: options =>
{
options.ConnectionString = "localhost:6379";
options.Database = 0;
options.UseJson = true; // Serializes grain state as JSON
options.KeyPrefix = "grain-"; // Optional prefix for Redis keys
});
});
// Run the host
await builder.RunAsync();
Example - Using Grain Storage in a Grain
// Define grain state class
public class MyGrainState
{
public string Data { get; set; }
public int Version { get; set; }
}
// Grain implementation that uses Redis storage
public class MyGrain : Grain, IMyGrain, IGrainWithStringKey
{
private readonly IPersistentState<MyGrainState> _state;
public MyGrain([PersistentState("state", "redisStore")] IPersistentState<MyGrainState> state)
{
_state = state;
}
public async Task SetData(string data)
{
_state.State.Data = data;
_state.State.Version++;
await _state.WriteStateAsync();
}
public Task<string> GetData()
{
return Task.FromResult(_state.State.Data);
}
}
Documentation
For more comprehensive documentation, please refer to:
Feedback & Contributing
- If you have any issues or would like to provide feedback, please open an issue on GitHub
- Join our community on Discord
- Follow the @msftorleans Twitter account for Orleans announcements
- Contributions are welcome! Please review our contribution guidelines
- This project is licensed under the MIT license
No packages depend on Microsoft.Orleans.Persistence.Redis.
.NET 8.0
- Microsoft.Orleans.Analyzers (>= 9.2.0-preview3)
- System.Memory.Data (>= 8.0.1)
- System.IO.Pipelines (>= 8.0.0)
- System.IO.Hashing (>= 8.0.0)
- System.Collections.Immutable (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.ObjectPool (>= 8.0.11)
- Microsoft.Extensions.Logging.Debug (>= 8.0.1)
- Microsoft.Extensions.Logging.Console (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Hosting (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.CodeAnalysis.Workspaces.Common (>= 4.5.0)
- Microsoft.CodeAnalysis.Common (>= 4.5.0)
- Microsoft.CodeAnalysis.Analyzers (>= 3.11.0)
- Microsoft.AspNetCore.Connections.Abstractions (>= 8.0.11)
- StackExchange.Redis (>= 2.8.16)
- Microsoft.Orleans.Runtime (>= 9.2.0-preview3)
- Microsoft.Orleans.CodeGenerator (>= 9.2.0-preview3)
- Microsoft.Extensions.DependencyModel (>= 8.0.2)
Version | Downloads | Last updated |
---|---|---|
9.2.0-preview3 | 1 | 6/15/2025 |
9.2.0-preview2 | 1 | 6/9/2025 |
9.2.0-preview1 | 1 | 6/9/2025 |
9.1.2 | 1 | 6/9/2025 |
9.0.1 | 1 | 6/9/2025 |
9.0.0 | 1 | 6/9/2025 |
8.2.0 | 1 | 6/9/2025 |
8.2.0-preview1 | 1 | 6/9/2025 |
8.1.0 | 1 | 6/8/2025 |
8.1.0-preview3 | 2 | 6/8/2025 |
8.1.0-preview2 | 1 | 6/9/2025 |
8.1.0-preview1 | 1 | 6/9/2025 |
8.0.0 | 1 | 6/9/2025 |
8.0.0-rc2 | 1 | 6/9/2025 |
8.0.0-rc1 | 1 | 6/9/2025 |
7.2.7 | 1 | 6/9/2025 |
7.2.6 | 1 | 6/9/2025 |
7.2.5 | 1 | 6/9/2025 |
7.2.4 | 1 | 6/9/2025 |
7.2.3 | 1 | 6/9/2025 |
7.2.2 | 1 | 6/9/2025 |
7.2.1 | 1 | 6/9/2025 |
7.2.0 | 1 | 6/9/2025 |
7.1.2-beta1 | 1 | 6/9/2025 |
7.1.1-beta1 | 1 | 6/9/2025 |
7.1.0-beta1 | 1 | 6/9/2025 |