STORAGE PROVIDERS

Choose your
storage.

Keep a consistent document API.
Choose storage based on persistence, sharing, and query needs.

Provider behavior at a glance
CapabilityMemoryFileSystemRedisPostgreSQL
Documents live inProcess memoryMemory + JSON fileRedisPostgreSQL
PersistenceTemporaryPeriodic save (~5s)Write-through¹Committed writes
Shared across instancesNoNoYesYes
Index lifetimeUntil unloadRebuilt on reloadPersisted in RedisPersisted in PostgreSQL
Atomic batchesYesYes, saved immediatelyYesYes

¹ Redis persistence and eviction configuration determine durability. FileSystem uses one database owner per file; call Save() to flush explicitly.

01 / IN PROCESS

Memory

For temporary data, tests, and applications that don’t need storage to survive a restart. No external service to configure.

Package on NuGet ↗
INSTALL
dotnet add package Soenneker.Librarian.Memory
REGISTER
using Soenneker.Librarian.Memory.Registrars;

builder.Services.AddMemoryLibrarianDatabaseAsSingleton();

Scoped registrations are also available. A scoped memory database owns its own data.

02 / LOCAL JSON

FileSystem

In-memory access with a JSON file behind it. Designed for a single database owner, with periodic saves and immediate persistence for atomic batches.

Await database.Save() for an explicit flush. Dispose the database’s owner asynchronously to complete shutdown persistence.

INSTALL & REGISTER
dotnet add package Soenneker.Librarian.FileSystem
C#
using Soenneker.Librarian.FileSystem.Registrars;

builder.Services.AddFileSystemLibrarianDatabaseAsSingleton();
APPSETTINGS.JSON
{
  "Librarian": {
    "FileSystem": { "FilePath": "data/librarian.json" }
  }
}
03 / SHARED STORAGE

Redis

Shared documents and persisted indexes for multiple application instances. Reads fetch current Redis data; writes update documents and indexes together.

No RedisJSON, Redis Search, or Lua required. Use a non-evicting database; cluster deployments require Redis 8 or later.

Redis setup & guarantees ↗
INSTALL
dotnet add package Soenneker.Librarian.Redis
C#
using Soenneker.Librarian.Redis.Registrars;

builder.Services.AddRedisLibrarianDatabaseAsSingleton();
APPSETTINGS.JSON
{
  "Azure": { "Redis": { "ConnectionString": "localhost:6379" } },
  "Librarian": {
    "Redis": { "Key": "my-app:librarian" }
  }
}
04 / PERSISTENT SQL

PostgreSQL

Shared persistent documents with SQL-backed filtering, sorting, paging, and aggregates. Writes and conditional batches commit immediately.

Indexes persist across restarts. Requires PostgreSQL 16 or later. Supply connection credentials through your application’s secret configuration.

PostgreSQL setup & queries ↗
INSTALL
dotnet add package Soenneker.Librarian.Postgres
C#
using Soenneker.Librarian.Postgres.Registrars;

builder.Services.AddPostgresLibrarianDatabaseAsSingleton();

Configure Librarian:Postgres:ConnectionString and Librarian:Postgres:Key.

Same API. Know the differences.

Memory and FileSystem can fall back to local evaluation for unsupported queries. Redis and PostgreSQL throw NotSupportedException. Review query support before moving a workload between providers.

Compare query capabilities ↗