Skip To Content

Getting Started

Install the server and connect a .NET client.

This guide walks through running a squirix server and connecting a .NET client.

Already using ASP.NET Core HybridCache? See switching from Redis or Garnet to Squirix for the Squirix adapter.

Prerequisites:

  • .NET 10 SDK to run the examples below.
  • Release packages built from the current source tree support both .NET 10 and .NET 11.
  • Building repository sources uses the SDK selected by global.json.
  • Docker Desktop with Linux containers for the Docker examples; the client example requires Compose 2.17 or newer.
  • For local HTTPS (tests, benchmarks, examples; not Docker): dotnet dev-certs https --trust

1. Run a development server

Choose one of the server options below. Leave that server running while using the client; stop it before trying another option on the same port. The local console example uses the global tool. Docker has a separate client example that handles its development JWT and certificate setup.

NuGet global tool

dotnet tool install --global squirix.server.tool --version 0.2.0-preview.1
squirix-server run

These commands use 0.2.0-preview.1. See the root README for the current package version.

The host listens on https://localhost:5001 by default (loopback bind), runs as an in-memory cache, and prints ready-to-use client and operational endpoint URLs. No JWT is required on this default URL — any local process can access the cache API. This is a development convenience, not production hardening. See server-mode.md — Loopback development default.

To use journal/snapshot persistence instead, stop the in-memory server with Ctrl+C and restart it with:

squirix-server run --persist --data-dir data

Health probes use the management HTTPS listener (local tool default port 5003):

curl https://localhost:5003/health

To expose the Prometheus endpoint, start the server with squirix-server run --metrics and enable Prometheus export in the settings file.

curl https://localhost:5003/metrics

/metrics accepts loopback connections without a token even when JWT authentication is enabled.

If the server cannot bind to port 5001, or the client reports a TLS chain error such as PartialChain, check that the CLI started successfully and that the endpoint belongs to that process. A container or another server already using the port may answer the health probe with a different certificate. If port 5001 is in use, start the CLI with squirix-server run --urls https://localhost:5443 (if 5443 is free). Use port 5443 in the client example and the management URL printed by the CLI for health probes (port 5445 by default). Keep TLS verification enabled.

Docker

For a first client connection in Docker, follow the complete Compose example. It starts three persistent RF=3 nodes and handles the development JWT and HTTPS certificate for the client container. The sample credentials and certificates are for local development only.

To start a single node or choose between source and release images, see Containerization.

From this repository

Run this alternative from the repository root with its selected SDK. It starts the server built from the current checkout, which may contain unreleased changes:

dotnet run --project src/squirix.server.host/Squirix.Server.Host.csproj -- run

2. Add the client SDK

Keep the server running. In a second terminal, create a console app. If you started the server from source, change to the repository root before creating the app.

dotnet new console --framework net10.0 -o SquirixDemo

For the server tool, install the matching SDK package:

dotnet add SquirixDemo/SquirixDemo.csproj package squirix --version 0.2.0-preview.1

If you started the server from this checkout, run the following command from the repository root to reference the SDK from the same checkout:

dotnet add SquirixDemo/SquirixDemo.csproj reference src/squirix/Squirix.csproj

3. Connect and use a typed cache

Use the public TLS endpoint from the host output.

Local tool or dotnet run (default https://localhost:5001, no JWT unless you configure auth):

Replace SquirixDemo/Program.cs with:

using System;
using System.Threading;
using Squirix.Client;

using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(15));
var cancellationToken = timeout.Token;

await using var client = await SquirixClient.ConnectAsync(new Uri("https://localhost:5001"), cancellationToken);

var cache = await client.GetCacheAsync<string>("demo", cancellationToken);
await cache.SetAsync("greeting", "hello", null, cancellationToken);

var lookup = await cache.GetValueAsync("greeting", cancellationToken);
Console.WriteLine(lookup.Found ? lookup.Value : "<missing>");

Run the app:

dotnet run --project SquirixDemo

Expected output: hello.

This example uses a string. For application-specific value types, register a source-generated JSON context as shown in Serialization.

Docker Compose: use the complete client example. It generates a short-lived development JWT and trusts the cluster's HTTPS certificate only inside its own container. Follow that example's startup, readiness checks, and client command in order. A container being listed as running does not mean its replica groups are ready.

Expected output: Found=True; Value=hello from Docker. For a reproducible leader-crash scenario, see the failover demo. The client connects to Compose DNS names on port 5000. Host applications instead use the published ports 5001–5003, options.BearerTokenProvider, and a properly trusted server certificate. The public client has no certificate-validation override option; do not disable TLS verification. See HTTPS in containers.

Multiple bootstrap endpoints (HA front door, not shards):

using System;
using System.Threading;
using Squirix.Client;

using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(15));
var cancellationToken = timeout.Token;

await using var client = await SquirixClient.ConnectAsync(
    static options =>
    {
        options.Endpoints.Add(new Uri("https://cache-a.example.internal:5001"));
        options.Endpoints.Add(new Uri("https://cache-b.example.internal:5002"));
    },
    cancellationToken);

See bootstrap client failover and configuration.

CLI reference

squirix-server init [--settings Squirix.settings.json]
squirix-server validate-config --settings Squirix.settings.json [--strict]
squirix-server doctor [--settings Squirix.settings.json]
squirix-server version

Square brackets in the command synopsis mark optional arguments; omit the brackets when running a command. init creates a settings file once and refuses to overwrite an existing file. --strict performs optional-section validation on validate-config; it does not add that validation to doctor or run.

run supports --urls, --persist, --data-dir (with --persist), --settings, --enable-replication, and --metrics. Run validate-config --settings Squirix.settings.json --strict before starting the server; passing --strict to run does not perform that validation. Without --settings, the host discovers Squirix.settings.json or squirix.settings.json in the working directory and application directory.

Use paths such as Squirix.settings.json or config/node.json; operator-supplied paths containing . or .. segments are rejected. Relative paths are resolved against the process working directory.

For settings outside the standard discovery locations, --settings selects the cluster and Prometheus export settings. Other optional runtime sections still use standard file discovery.

Next steps