@statesync/persistence / PersistedSnapshotMetadata
Interface: PersistedSnapshotMetadata
Defined in: persistence/src/types.ts:82
Metadata stored alongside a persisted snapshot for integrity checking, expiration management, and schema migration.
This metadata is written to storage by backends that implement StorageBackendWithMetadata and is used during load to decide whether the snapshot is still valid.
Properties
compressed
compressed: boolean;Defined in: persistence/src/types.ts:111
Whether the snapshot data was compressed before storage.
When true, the data must be decompressed using the same CompressionAdapter that was used during save.
hash?
optional hash: string;Defined in: persistence/src/types.ts:119
Optional integrity hash of the serialized (and possibly compressed) data.
Computed using a non-cryptographic hash function. Verified during load when the verifyHash option is enabled in LoadOptions.
savedAt
savedAt: number;Defined in: persistence/src/types.ts:88
Timestamp when the snapshot was saved, in milliseconds since the Unix epoch.
Used together with ttlMs to determine cache expiration.
schemaVersion
schemaVersion: number;Defined in: persistence/src/types.ts:96
Schema version number at the time the snapshot was saved.
Compared against the current version during load to determine whether data migration is needed. Versions are sequential positive integers.
sizeBytes
sizeBytes: number;Defined in: persistence/src/types.ts:103
Size of the serialized JSON data in bytes, measured before compression.
Useful for observability and storage quota estimation.
ttlMs?
optional ttlMs: number;Defined in: persistence/src/types.ts:128
Time-to-live in milliseconds. When set, the cached snapshot is considered expired if Date.now() - savedAt > ttlMs.
Expired snapshots are discarded during load unless ignoreTTL is set in LoadOptions.
