/** * Snapshot Manager Implementation * Handles RAM tier persistence and recovery through snapshots * Requirements: 11.2, 11.3, 11.4 */ import { StorageTier } from '../storage/StorageTier.js'; import { TierManager } from '../tier/TierManager.js'; /** * Entry in a RAM snapshot containing key data and metadata */ export interface SnapshotEntry { /** The cache key */ key: string; /** The value as base64-encoded string (for JSON serialization) */ value: string; /** Unix timestamp (ms) when this key expires, null if no expiration */ expiresAt: number | null; /** Access count for the key */ accessCount: number; /** Unix timestamp (ms) of last access */ lastAccess: number; /** Unix timestamp (ms) when this key was created */ createdAt: number; /** Size of the value in bytes */ sizeBytes: number; } /** * RAM tier snapshot for persistence * Requirement 11.3: Support configurable persistence intervals for RAM_Tier snapshots */ export interface RamSnapshot { /** Snapshot format version for compatibility */ version: number; /** Unix timestamp (ms) when snapshot was created */ timestamp: number; /** Array of snapshot entries containing key-value pairs with metadata */ entries: SnapshotEntry[]; /** SHA-256 checksum of the entries for integrity validation */ checksum: string; } /** * SnapshotManager handles RAM tier persistence and recovery. * * Requirements: * - 11.2: Restore the tier index from persistent storage on startup * - 11.3: Support configurable persistence intervals for RAM_Tier snapshots * - 11.4: Recover from the last snapshot and SSD_Tier state on unexpected shutdown */ export declare class SnapshotManager { /** * Create a snapshot of the RAM tier. * Captures all key-value pairs with their metadata for persistence. * * @param ramTier - The RAM tier storage to snapshot * @param tierManager - The tier manager for accessing key metadata * @returns A RamSnapshot containing all RAM tier data */ createSnapshot(ramTier: StorageTier, tierManager: TierManager): Promise; /** * Save a snapshot to a file. * Creates the directory if it doesn't exist. * * @param snapshot - The snapshot to save * @param path - The file path to save to */ saveSnapshot(snapshot: RamSnapshot, snapshotPath: string): Promise; /** * Load a snapshot from a file. * Returns null if the file doesn't exist or is invalid. * * @param path - The file path to load from * @returns The loaded snapshot, or null if not found/invalid */ loadSnapshot(path: string): Promise; /** * Validate a snapshot's checksum. * * @param snapshot - The snapshot to validate * @returns true if the checksum is valid, false otherwise */ validateSnapshot(snapshot: RamSnapshot): boolean; /** * Restore RAM tier from a snapshot. * Loads all entries from the snapshot into the RAM tier and registers them in the tier manager. * * Requirement 11.2: Restore the tier index from persistent storage on startup * Requirement 11.4: Recover from the last snapshot and SSD_Tier state * * @param snapshot - The snapshot to restore from * @param ramTier - The RAM tier storage to restore to * @param tierManager - The tier manager to register keys with */ restoreFromSnapshot(snapshot: RamSnapshot, ramTier: StorageTier, tierManager: TierManager): Promise; /** * Calculate SHA-256 checksum of snapshot entries. * * @param entries - The entries to calculate checksum for * @returns The hex-encoded SHA-256 checksum */ private calculateChecksum; /** * Delete a snapshot file. * * @param path - The file path to delete * @returns true if deleted, false if file didn't exist */ deleteSnapshot(path: string): Promise; /** * Check if a snapshot file exists. * * @param path - The file path to check * @returns true if the file exists, false otherwise */ snapshotExists(path: string): Promise; } //# sourceMappingURL=SnapshotManager.d.ts.map