Class ActiveSlotKeyValueStore
IKeyValueStore that routes every entry through a CheckpointsSection
instead of an independent backend, so whatever is written through it travels inside the
active GameSave slot's own document rather than a separate, unrelated file or key space.
Inherited Members
Namespace: Serenity.GameSave.Infrastructure.Stores
Assembly: Serenity.GameSave.Infrastructure.dll
Syntax
public class ActiveSlotKeyValueStore : IKeyValueStore, IKeyedStore, IPersistenceStore
Remarks
This store holds no persistence logic of its own: every read/write delegates straight to the
injected CheckpointsSection, an in-memory map of checkpoint key to byte payload.
Save/load participation comes "for free" from the standard
IGameSaveService.RegisterSection
mechanism: registering the SAME section instance makes the game-save service serialize it into
the reserved CHECKPOINTS section
on every save, and hand it back on every load — this store never has to know a save or load
happened. With no active slot (or before the first load), the section simply holds whatever was
written this session, so quicksave/quickload keeps working within the running session.
Neither this class nor CheckpointsSection is referenced by
UnitySerenityInstaller, and nothing under the Checkpoint aggregate changes — the
Checkpoint side of this composition stays entirely game-side. On the GameSave side, however,
this routing is ON BY DEFAULT: UnityGameSaveInstaller registers a CheckpointsSection
with the installed service and builds this store automatically unless a project explicitly sets
UnityGameSaveSettings.RouteCheckpointsIntoActiveSlot to false — it is harmless and
costs nothing when a project never touches Checkpoint. The one step that remains genuinely
opt-in is the GAME handing the resulting store to its own Checkpoint installer:
// Inside the game's composition root, after installing GameSave:
var checkpointStore = gameSaveInstaller.GetCheckpointStore();
var checkpointInstaller = new UnityCheckpointInstaller(checkpointStore);
checkpointInstaller.Install(logService);
A project that wants full manual control (its own CheckpointsSection instance,
or a different IGameSaveService
than the one UnityGameSaveInstaller manages) can set
RouteCheckpointsIntoActiveSlot = false and compose this store itself:
var checkpointsSection = new CheckpointsSection();
gameSaveService.RegisterSection(checkpointsSection);
var checkpointKeyValueStore = new ActiveSlotKeyValueStore(checkpointsSection);
A deliberate deviation from routing every lifecycle event: deleting the currently active slot does NOT reset this store's in-memory map. Every other registered section (inventory, milestones, completion) keeps its live state across a delete too — a delete removes a slot's persisted file, not the running session's current state — so checkpoints follow the exact same, already-established convention instead of special-casing themselves.
Constructors
ActiveSlotKeyValueStore(CheckpointsSection, string)
Initializes a new instance of the ActiveSlotKeyValueStore class.
Declaration
public ActiveSlotKeyValueStore(CheckpointsSection checkpointsSection, string @namespace = "active-slot-checkpoints")
Parameters
| Type | Name | Description |
|---|---|---|
| CheckpointsSection | checkpointsSection | The section this store reads from and writes to. Register the SAME instance with the
game-save service ( |
| string | namespace | Logical namespace for diagnostics/telemetry. Defaults to DEFAULT_NAMESPACE. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Fields
DEFAULT_NAMESPACE
Default logical namespace identifying this store as checkpoints routed into the active save slot.
Declaration
public const string DEFAULT_NAMESPACE = "active-slot-checkpoints"
Field Value
| Type | Description |
|---|---|
| string |
Properties
Namespace
Declaration
public string Namespace { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
DeleteAsync(string, CancellationToken)
Declaration
public virtual Task DeleteAsync(string key, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
ExistsAsync(string, CancellationToken)
Declaration
public virtual Task<bool> ExistsAsync(string key, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
GetAsync(string, CancellationToken)
Declaration
public virtual Task<ReadOnlyMemory<byte>?> GetAsync(string key, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ReadOnlyMemory<byte>?> |
HealthCheckAsync(CancellationToken)
Declaration
public virtual Task<bool> HealthCheckAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
SetAsync(string, ReadOnlyMemory<byte>, CancellationToken)
Declaration
public virtual Task SetAsync(string key, ReadOnlyMemory<byte> value, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| ReadOnlyMemory<byte> | value | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |