SnapshotStore
API reference › Debug Core › Storage › SnapshotStore
Provides JSON filesystem storage, manifest locking, atomic writes, and snapshot garbage collection.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a filesystem store with directory and file permission modes. | SnapshotStore |
clear() | Removes stored manifests, snapshots, and temporary files. | SnapshotStore |
loadManifest() | Returns manifest entries ordered from newest to oldest. | SnapshotStore |
loadManifestResult() | Returns manifest entries and preserves any read diagnostic for observable error handling. | SnapshotStore |
readSnapshot() | Returns a stored snapshot or null when the tag or persisted payload is invalid. | SnapshotStore |
readSnapshotResult() | Returns a stored snapshot and preserves any read diagnostic for observable error handling. | SnapshotStore |
writeSnapshot() | Writes a snapshot, updates the manifest, and runs garbage collection under one exclusive lock. | SnapshotStore |
writeSnapshotResult() | Writes a snapshot and returns the already-hydrated committed manifest together with evicted entries. | SnapshotStore |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $path, int $dirMode, int|null $fileMode)Creates a filesystem store with directory and file permission modes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string | Storage directory path. |
$dirMode | int | Directory permissions used when creating the storage path. |
$fileMode | int| | File permissions or null to preserve the system default. |
clear()
Section titled “clear() ”public function clear(): voidRemoves stored manifests, snapshots, and temporary files.
loadManifest()
Section titled “loadManifest() ”public function loadManifest(): array<string, PHPForge\Debug\Storage\RequestSummary>Returns manifest entries ordered from newest to oldest.
Returns
array<string, RequestSummary>: Newest entries first.
loadManifestResult()
Section titled “loadManifestResult() ”public function loadManifestResult(): PHPForge\Debug\Storage\ManifestReadResultReturns manifest entries and preserves any read diagnostic for observable error handling.
Returns
ManifestReadResult: Newest entries first plus an optional storage failure.
readSnapshot()
Section titled “readSnapshot() ”public function readSnapshot(string $tag): PHPForge\Debug\Storage\DebugSnapshot|nullReturns a stored snapshot or null when the tag or persisted payload is invalid.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tag | string | Snapshot tag. |
Returns
DebugSnapshot|null: Hydrated snapshot or null when the stored value is unavailable or invalid.
readSnapshotResult()
Section titled “readSnapshotResult() ”public function readSnapshotResult(string $tag): PHPForge\Debug\Storage\SnapshotReadResultReturns a stored snapshot and preserves any read diagnostic for observable error handling.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tag | string | Snapshot tag. |
Returns
SnapshotReadResult: Snapshot, missing state, or storage failure.
writeSnapshot()
Section titled “writeSnapshot() ”public function writeSnapshot(PHPForge\Debug\Storage\DebugSnapshot $snapshot, int $historySize): list<PHPForge\Debug\Storage\RequestSummary>Writes a snapshot, updates the manifest, and runs garbage collection under one exclusive lock.
Parameters
| Parameter | Type | Description |
|---|---|---|
$snapshot | DebugSnapshot | Snapshot to persist. |
$historySize | int | Maximum number of retained entries. |
Returns
list<RequestSummary>: Entries evicted from the manifest.
writeSnapshotResult()
Section titled “writeSnapshotResult() ”public function writeSnapshotResult(PHPForge\Debug\Storage\DebugSnapshot $snapshot, int $historySize): PHPForge\Debug\Storage\SnapshotWriteResultWrites a snapshot and returns the already-hydrated committed manifest together with evicted entries.
Adapters that need the resulting manifest can consume this result without acquiring the lock and decoding the index a second time.
Parameters
| Parameter | Type | Description |
|---|---|---|
$snapshot | DebugSnapshot | Snapshot to persist. |
$historySize | int | Maximum number of retained entries. |
Returns
SnapshotWriteResult: Committed manifest and entries evicted from it.