/** * File Organizer MCP Server v3.4.2 * Metadata Cache Service * Caches metadata extractions for audio and image files */ import { AudioMetadata, ImageMetadata } from "../types.js"; export interface CacheStats { entries: number; size: number; hits: number; misses: number; } import { MetadataCacheOptions, MetadataCacheEntry } from "../types.js"; export declare class MetadataCacheService { private readonly cacheDir; private readonly maxAge; private readonly maxEntries; private readonly cacheFilePath; private writeLock; private initLock; private memoryCache; private stats; private initialized; private statsCache; private lastModified; constructor(options?: MetadataCacheOptions); /** * Initialize the cache directory */ initialize(): Promise; /** * Generate a hash for a file based on path and modification time */ private generateFileHash; /** * Load cache from disk into memory * SECURITY JUSTIFICATION (SEC-001, SEC-016): * this.cacheFilePath is an internal application path constructed in the constructor * from this.cacheDir (defaults to ".cache" in cwd). It is NOT user-provided input. * Therefore, no path validation is required per the security model. * JSON.parse is safe here because we're parsing the application's own cache file * that was created by this service, not untrusted user input. */ private loadFromDisk; /** * Save cache to disk */ private saveToDisk; /** * Acquire write lock for atomic operations */ private acquireLock; /** * Get cached value by key */ get(key: string): Promise; /** * Set cached value with optional TTL */ set(key: string, value: unknown, options?: { ttl?: number; filePath?: string; }): Promise; /** * Delete a cached entry */ delete(key: string): Promise; /** * Clear all cached entries */ clear(): Promise; /** * Check if a key exists in cache */ has(key: string): Promise; /** * Check if a file-based cache entry is stale */ private isFileStale; /** * Check if a key is stale (for file-based caching) */ isStale(key: string): Promise; /** * Prune expired entries */ prune(): Promise; /** * Get cache statistics with 5-second caching to avoid expensive recalculation */ getStats(): Promise; /** * Get cached metadata for a file if valid */ getFileMetadata(filePath: string): Promise; /** * Read the legacy cache file * SECURITY JUSTIFICATION (SEC-001, SEC-016): * this.cacheFilePath is an internal application path constructed in the constructor * from this.cacheDir (defaults to ".cache" in cwd). It is NOT user-provided input. * Therefore, no path validation is required per the security model. * JSON.parse is safe here because we're parsing the application's own cache file * that was created by this service, not untrusted user input. */ private readLegacyCache; /** * Write cache to file atomically */ private writeCache; /** * Cache metadata for a file */ setFileMetadata(filePath: string, metadata: AudioMetadata | ImageMetadata): Promise; /** * Cache metadata for multiple files in bulk */ setBatch(metadataEntries: Array<{ filePath: string; metadata: AudioMetadata | ImageMetadata; }>): Promise; /** * Get cached metadata for multiple files */ getBatch(filePaths: string[]): Promise; /** * Remove a specific entry from the cache */ invalidate(filePath: string): Promise; /** * Clear the entire cache */ invalidateAll(): Promise; /** * Get legacy cache statistics */ getFileCacheStats(): Promise<{ totalEntries: number; audioEntries: number; imageEntries: number; cacheSize: number; }>; /** * Remove expired entries from cache */ cleanup(): Promise; /** * Check if a file has valid cached metadata */ hasFile(filePath: string): Promise; /** * Get all cached entries (for debugging/admin purposes) */ getAllEntries(): Promise; } export declare const globalMetadataCache: MetadataCacheService; //# sourceMappingURL=metadata-cache.service.d.ts.map