/** * @fileoverview Caching infrastructure * @module @nahisaho/musubix-security/infrastructure/cache * @trace REQ-SEC-CACHE-001 */ import type { CacheStrategy } from '../types/index.js'; /** * Cache statistics */ export interface CacheStats { hits: number; misses: number; size: number; entryCount: number; hitRate: number; } /** * Cache options */ export interface CacheOptions { /** Cache strategy */ strategy: CacheStrategy; /** Cache directory for file strategy */ cacheDir?: string; /** TTL in seconds */ ttlSeconds?: number; /** Maximum cache size in bytes */ maxSizeBytes?: number; } /** * Abstract cache interface */ export interface ICache { get(key: string): Promise; set(key: string, value: T, ttlSeconds?: number): Promise; has(key: string): Promise; delete(key: string): Promise; clear(): Promise; getStats(): CacheStats | Promise; } /** * Memory cache implementation */ export declare class MemoryCache implements ICache { private cache; private stats; private maxSizeBytes; private defaultTtlSeconds; private currentSize; constructor(options?: CacheOptions); get(key: string): Promise; set(key: string, value: T, ttlSeconds?: number): Promise; has(key: string): Promise; delete(key: string): Promise; clear(): Promise; getStats(): CacheStats; private evictOldest; } /** * File-based cache implementation */ export declare class FileCache implements ICache { private stats; private cacheDir; private defaultTtlSeconds; private initialized; constructor(options: CacheOptions); private ensureDir; private getCachePath; get(key: string): Promise; set(key: string, value: T, ttlSeconds?: number): Promise; has(key: string): Promise; delete(key: string): Promise; clear(): Promise; getStats(): Promise; } /** * No-op cache implementation */ export declare class NoopCache implements ICache { get(_key: string): Promise; set(_key: string, _value: T): Promise; has(_key: string): Promise; delete(_key: string): Promise; clear(): Promise; getStats(): CacheStats; } /** * Create a cache instance based on options */ export declare function createCache(options: CacheOptions): ICache; /** * Generate a cache key from multiple parts */ export declare function cacheKey(...parts: (string | number | boolean | undefined | null)[]): string; /** * Generate a hash for a file's content */ export declare function contentHash(content: string): string; //# sourceMappingURL=cache.d.ts.map