Run in-process
In-process mode runs the Zaris store inside your application process, with no servers to install and no cluster to configure. This is the fastest way to get a working store, and it uses the exact same client API as a cluster.
In-process mode is not a different API or a different code path — it is just a connection string. The string zaris://inproc/<store> creates an embedded store that holds its data in memory for as long as your application runs. When you later need to scale or coordinate across instances, you swap that string for one that points at a cluster (zaris://host:port/<store>). Nothing else in your code changes.
Prerequisites
You need a .NET project and the .NET SDK. No Zaris installation is required for in-process mode.
1. Create a project
Create a console project to hold the example. Skip this step if you already have a project.
dotnet new console -o zaris-demo
cd zaris-demo
2. Install the package
Add the Zaris SDK to your project with the dotnet CLI:
dotnet add package Clustron.Zaris.SDK
3. Add the connection string
Put the connection string in appsettings.json under the standard ConnectionStrings section, keyed by a name you choose. The value zaris://inproc/demo selects an in-process store named demo (inproc is a reserved host token, like localhost):
{
"ConnectionStrings": {
"demo": "zaris://inproc/demo"
}
}
4. Register the store
Register the store from configuration. AddClustronZaris(configuration, "demo") looks up ConnectionStrings:demo and wires up the provider that hands out clients.
using Clustron.Zaris.Client.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection()
.AddClustronZaris(configuration, "demo")
.BuildServiceProvider();
5. Get a client
Resolve a client for the demo store from the service provider. You use this client for every store operation.
var client = await services
.GetRequiredService<IZarisClientProvider>()
.GetAsync("demo");
6. Store and read a value
Store a value with PutAsync, then read it back with GetAsync. The type argument on GetAsync<string> tells Zaris how to deserialize the value.
await client.PutAsync("hello", "world");
var value = await client.GetAsync<string>("hello");
Console.WriteLine(value.Value);
Without dependency injection
If you don't have a DI container, connect imperatively with the same connection string. ZarisClient.ConnectAsync is the single entry point; it parses the string and returns a connected client.
using Clustron.Zaris.Client;
var client = await ZarisClient.ConnectAsync("zaris://inproc/demo");
await client.PutAsync("hello", "world");
var value = await client.GetAsync<string>("hello");
Console.WriteLine(value.Value);
A literal string like this is fine for a quick sample; in a real app, prefer ZarisClient.ConnectAsync(configuration.GetConnectionString("demo")!) so the value comes from configuration.
Complete example
The steps above combine into a single top-level program. Copy this into Program.cs and run it with dotnet run. It prints world.
using Clustron.Zaris.Client;
var client = await ZarisClient.ConnectAsync("zaris://inproc/demo");
await client.PutAsync("hello", "world");
var value = await client.GetAsync<string>("hello");
Console.WriteLine(value.Value);
What you just did
You created a working key-value store that runs entirely inside your process. No network calls or external services were involved, and you used the same client API that a cluster uses. Because there is no network hop, in-process mode is the fastest way to run the store.
Move to a cluster
When your application needs to scale or coordinate across multiple instances, point the store at a running cluster. The only change is the connection string: replace zaris://inproc/demo with a seed address, zaris://host:port/demo (or zariss:// for TLS):
{
"ConnectionStrings": {
"demo": "zaris://localhost:7861/demo"
}
}
Your code in steps 4 through 6 is unchanged — the same registration, the same GetAsync, the same operations. To run the node that this string connects to, install Zaris and create a store.