UNPKG

@aradox/multi-orm

Version:

Type-safe ORM with multi-datasource support, row-level security, and Prisma-like API for PostgreSQL, SQL Server, and HTTP APIs

69 lines 1.69 kB
/** * Query Result Cache * * In-memory cache with TTL (time-to-live) and LRU (least recently used) eviction. * Provides caching for query results to reduce database load. */ export interface CacheOptions { /** Time to live in milliseconds (default: 60000 = 1 minute) */ ttl?: number; /** Maximum number of cache entries (default: 1000) */ maxSize?: number; /** Enable/disable cache (default: true) */ enabled?: boolean; } export interface CacheEntry<T> { key: string; value: T; expiry: number; lastAccessed: number; hits: number; } export declare class QueryCache { private cache; private options; constructor(options?: CacheOptions); /** * Get cached value by key */ get<T>(key: string): T | null; /** * Set cache value with key */ set<T>(key: string, value: T, ttl?: number): void; /** * Invalidate (delete) cache entry by key */ invalidate(key: string): boolean; /** * Invalidate cache entries matching pattern */ invalidatePattern(pattern: string | RegExp): number; /** * Clear all cache entries */ clear(): void; /** * Get cache statistics */ stats(): { size: number; maxSize: number; hitRate: number; totalHits: number; totalMisses: number; }; /** * Evict least recently used entry */ private evictLRU; /** * Remove expired entries */ private cleanup; /** * Generate cache key from query parameters */ static generateKey(model: string, operation: string, args: any): string; } //# sourceMappingURL=cache.d.ts.map