Skip to content

Memory grain persistence

The Microsoft.Orleans.Persistence.Memory package stores grain state inside the Orleans cluster. Use it for tests, samples, and disposable local development environments.

Configure a named provider with AddMemoryGrainStorage:

siloBuilder.AddMemoryGrainStorage(
name: "development",
configureOptions: options =>
{
options.NumStorageGrains = 10;
});

The provider name must match the storage name in [PersistentState].

Use AddMemoryGrainStorageAsDefault when grains should use memory storage without specifying a storage name:

siloBuilder.AddMemoryGrainStorageAsDefault();

NumStorageGrains controls how many internal storage grains distribute the records. The default is 10 and the value must be greater than zero.

Memory storage still serializes state through IGrainStorageSerializer, so it can expose serialization and schema errors during tests. It doesn’t model the latency, availability, capacity, concurrency, or operational behavior of an external production store.