evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Implement a tiny cache helper that writes and reads content while enforcing integrity digests, size limits, and allowed hashing algorithms. The helper must make it easy to reject corrupted data, reuse external hashing efforts, and confirm the algorithm that validated the content.
export interface CacheConfig {
cachePath: string;
algorithms?: string[];
}
export interface WriteOptions {
expectedIntegrity?: string;
size?: number;
integrityEmitter?: import('events').EventEmitter;
}
export interface ReadOptions {
expectedIntegrity?: string;
size?: number;
algorithms?: string[];
}
export interface CacheClient {
write(key: string, data: Buffer | string, opts?: WriteOptions): Promise<{ integrity: string; size: number }>;
read(key: string, opts?: ReadOptions): Promise<{ data: Buffer; integrity: string; size: number; algorithm: string }>;
}
export function createCacheClient(config: CacheConfig): CacheClient;Content-addressable cache with integrity and size enforcement features.