SetNet.Persistence
1.2.0
dotnet add package SetNet.Persistence --version 1.2.0
NuGet\Install-Package SetNet.Persistence -Version 1.2.0
<PackageReference Include="SetNet.Persistence" Version="1.2.0" />
<PackageVersion Include="SetNet.Persistence" Version="1.2.0" />
<PackageReference Include="SetNet.Persistence" />
paket add SetNet.Persistence --version 1.2.0
#r "nuget: SetNet.Persistence, 1.2.0"
#:package SetNet.Persistence@1.2.0
#addin nuget:?package=SetNet.Persistence&version=1.2.0
#tool nuget:?package=SetNet.Persistence&version=1.2.0
<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>
SetNet.Persistence
A durable-state seam for SetNet module stores — one interface, in-memory or JSON-file out of the box, your Redis/DB behind the same shape.
Most SetNet modules keep their state (inventories, wallets, progression, mail queues, save-games) behind a small store interface that defaults to an in-process dictionary. This package gives those seams something durable: IDocumentStore<T> for keyed values and ISnapshotStore for opaque blobs, each with a memory implementation for tests and a file implementation for dev — swap in a Redis/DB store later without touching callers. No wire protocol; pure storage.
Install
dotnet add package SetNet
dotnet add package SetNet.Persistence
Usage
// keyed documents — get/set/remove/enumerate by key
IDocumentStore<PlayerSave> saves = new JsonFileDocumentStore<PlayerSave>("data/saves.json");
await saves.SetAsync(playerKey, new PlayerSave { Level = 12, Gold = 500 });
PlayerSave? save = await saves.GetAsync(playerKey);
IReadOnlyList<string> keys = await saves.KeysAsync();
// opaque blobs — world snapshots, serialized module state
ISnapshotStore snaps = new FileSnapshotStore("data/snapshots");
await snaps.SaveAsync("world", worldBytes);
byte[]? bytes = await snaps.LoadAsync("world");
// tests / single-node: in-process, non-durable
IDocumentStore<PlayerSave> mem = new MemoryDocumentStore<PlayerSave>();
API
Documents: IDocumentStore<T> — GetAsync, SetAsync, RemoveAsync, ExistsAsync, KeysAsync, AllAsync.
Implementations: MemoryDocumentStore<T>, JsonFileDocumentStore<T>(path, JsonSerializerOptions?).
Snapshots: ISnapshotStore — SaveAsync, LoadAsync, DeleteAsync.
Implementations: MemorySnapshotStore, FileSnapshotStore(directory).
Notes
- A seam, not a hub. There's no
UseX()and noRuntime.Enable()— this is plumbing. Pass one of these stores wherever a module accepts its store interface, or implement the module's own store interface on top of anIDocumentStore<T>. - Memory for tests, file for dev, your own at scale.
MemoryDocumentStore<T>/MemorySnapshotStoreare in-process and non-durable.JsonFileDocumentStore<T>keeps a single human-readablekey → valuemap, loaded on construction and rewritten (via a temp-file swap) on every mutation — great for small/medium data; move to a database at scale.FileSnapshotStorewrites one<name>.snapshotfile per blob. - Thread-safe. The file document store guards reads and writes with a lock; the memory stores use
ConcurrentDictionary. System.Text.Json.JsonFileDocumentStore<T>serializes withSystem.Text.Json(WriteIndentedby default) — pass your ownJsonSerializerOptionsto control naming, converters, etc. Make sureTis round-trippable.
Documentation & source
- 🐙 https://github.com/Povstalez/SetNet — full catalog in docs/MODULES.md
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- SetNet (>= 1.2.0)
- System.Text.Json (>= 8.0.5)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on SetNet.Persistence:
| Package | Downloads |
|---|---|
|
SetNet.Accounts
Account store + authentication for SetNet: a generic AccountServer<TAccount> over any IDocumentStore (memory/file/SQL/Mongo). Register/authenticate with a pluggable password hasher (PBKDF2 default), ban/unban, change password. Subclass AccountBase (or use its Extra bag) to add ANY custom fields with no schema change. Pairs with SetNet.LoginServer. Depends on SetNet + SetNet.Persistence. |
|
|
SetNet.Persistence.EfCore
Entity Framework Core-backed IDocumentStore<T> / ISnapshotStore for SetNet.Persistence. Provider-agnostic — pass DbContextOptions configured for SQLite / PostgreSQL / SQL Server / etc. Each value is stored as JSON in a key/value table, so custom fields need no schema change. Depends on SetNet.Persistence + Microsoft.EntityFrameworkCore(.Relational). |
|
|
SetNet.Persistence.Postgres
PostgreSQL-backed IDocumentStore<T> / ISnapshotStore for SetNet.Persistence via Npgsql. Each value is stored in a JSONB column, so custom fields need no schema change AND stay queryable/indexable in SQL (e.g. WHERE doc->>'vipUntil' > now()). Native upsert (INSERT … ON CONFLICT). Depends on SetNet.Persistence + Npgsql. |
|
|
SetNet.Persistence.MongoDB
MongoDB-backed IDocumentStore<T> / ISnapshotStore for SetNet.Persistence via MongoDB.Driver. Each value is stored as a native BSON document, so custom fields need no schema change AND stay queryable/indexable in Mongo. Upsert via ReplaceOne(IsUpsert). Depends on SetNet.Persistence + MongoDB.Driver. |
|
|
SetNet.Persistence.Dapper
Dapper-backed IDocumentStore<T> / ISnapshotStore for SetNet.Persistence: store any POCO as JSON in a key/value table on any ADO.NET database (SQLite, PostgreSQL, MySQL, SQL Server, …). Custom fields need no schema change — the whole object is serialized. Portable upsert (delete+insert in a transaction). Depends on SetNet.Persistence + Dapper. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.0 | 293 | 8/5/2026 |