organ-ai-zer
Version:
AI-powered file organizer CLI tool
79 lines • 2.31 kB
TypeScript
import { FileInfo } from '../types';
export interface CachedData<T> {
data: T;
directoryHash: string;
timestamp: number;
fileCount: number;
configHash?: string;
}
export interface CacheConfig {
subDirectory: string;
ttlMs: number;
filePrefix?: string;
useConfigHash?: boolean;
}
export interface CacheStats {
memoryEntries: number;
diskCacheDir: string;
ttlMs: number;
subDirectory: string;
}
/**
* Base cache class providing common caching functionality
* All specific cache implementations should extend this class
*/
export declare abstract class BaseCache<T> {
protected memoryCache: Map<string, CachedData<T>>;
protected readonly cacheDir: string;
protected readonly config: CacheConfig;
constructor(config: CacheConfig);
/**
* Get cached data for a directory
*/
getCached(directory: string, files: FileInfo[], configHash?: string): Promise<T | null>;
/**
* Cache data for a directory
*/
cache(directory: string, files: FileInfo[], data: T, configHash?: string): Promise<void>;
/**
* Clear cache for specific directory or all
*/
clearCache(directory?: string): Promise<void>;
/**
* Get cache statistics
*/
getCacheStats(): CacheStats;
/**
* Clean expired cache entries
*/
cleanExpiredCache(): Promise<void>;
/**
* Get all cached directories
*/
getCachedDirectories(): Promise<string[]>;
/**
* Generate cache key for directory
*/
protected getCacheKey(directory: string): string;
/**
* Calculate hash of directory contents for change detection
*/
protected calculateDirectoryHash(files: FileInfo[]): string;
/**
* Check if cached data is still valid
*/
protected isValidCache(cache: CachedData<T>, currentDirectoryHash: string, currentConfigHash?: string): boolean;
/**
* Get disk cache file path
*/
protected getDiskCachePath(cacheKey: string): string;
/**
* Load cached data from disk
*/
protected loadFromDisk(cacheKey: string): Promise<CachedData<T> | null>;
/**
* Save cached data to disk
*/
protected saveToDisk(cacheKey: string, data: CachedData<T>): Promise<void>;
}
//# sourceMappingURL=base-cache.d.ts.map