@git.zone/tsdoc
Version:
A comprehensive TypeScript documentation tool that leverages AI to generate and enhance project documentation, including dynamic README creation, API docs via TypeDoc, and smart commit message generation.
74 lines (73 loc) • 2.04 kB
TypeScript
import type { ICacheEntry, ICacheConfig } from './types.js';
/**
* ContextCache provides persistent caching of file contents and token counts
* with automatic invalidation on file changes
*/
export declare class ContextCache {
private cacheDir;
private cache;
private config;
private cacheIndexPath;
/**
* Creates a new ContextCache
* @param projectRoot - Root directory of the project
* @param config - Cache configuration
*/
constructor(projectRoot: string, config?: Partial<ICacheConfig>);
/**
* Initializes the cache by loading from disk
*/
init(): Promise<void>;
/**
* Gets a cached entry if it's still valid
* @param filePath - Absolute path to the file
* @returns Cache entry if valid, null otherwise
*/
get(filePath: string): Promise<ICacheEntry | null>;
/**
* Stores a cache entry
* @param entry - Cache entry to store
*/
set(entry: ICacheEntry): Promise<void>;
/**
* Stores multiple cache entries
* @param entries - Array of cache entries
*/
setMany(entries: ICacheEntry[]): Promise<void>;
/**
* Checks if a file is cached and valid
* @param filePath - Absolute path to the file
* @returns True if cached and valid
*/
has(filePath: string): Promise<boolean>;
/**
* Gets cache statistics
*/
getStats(): {
entries: number;
totalSize: number;
oldestEntry: number | null;
newestEntry: number | null;
};
/**
* Clears all cache entries
*/
clear(): Promise<void>;
/**
* Clears specific cache entries
* @param filePaths - Array of file paths to clear
*/
clearPaths(filePaths: string[]): Promise<void>;
/**
* Cleans up expired and invalid cache entries
*/
private cleanup;
/**
* Enforces maximum cache size by evicting oldest entries
*/
private enforceMaxSize;
/**
* Persists cache index to disk
*/
private persist;
}