/** * 通用 LRU + TTL 缓存(图像/结果/模型共用基础实现) */ import type { OcrImageData, OcrResult } from "../typings"; export interface CacheOptions { maxSize?: number; maxCount?: number; ttl?: number; } export declare class LruCache { private store; private bytes; private readonly maxBytes; private readonly maxEntries; private readonly ttl; constructor(opts?: CacheOptions); get(key: string): V | undefined; set(key: string, value: V, size?: number): void; has(key: string): boolean; delete(key: string): boolean; clear(): void; getStats(): { size: number; count: number; hitRate: number; totalHits: number; }; } /** 图像缓存(按 byteLength 计费) */ export declare class ImageCache { private cache; constructor(opts?: CacheOptions); get(key: string): OcrImageData | undefined; set(key: string, data: OcrImageData): void; has(key: string): boolean; clear(): void; } /** 结果缓存 */ export declare class ResultCache { private cache; constructor(opts?: CacheOptions); get(key: string): OcrResult | undefined; set(key: string, result: OcrResult): void; has(key: string): boolean; clear(): void; static key(imageHash: string, options: Record): string; }