UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

47 lines (46 loc) 1.45 kB
/** * 本地内存缓存服务 * 提供分布式缓存支持,提升 API 响应速度 * 生产环境建议通过 UnifiedCacheAdapter 接入 Redis */ /** 本地缓存实现(无 Redis 依赖) */ export declare class CacheService { cache: Map<string, { value: unknown; expiresAt: number; }>; cleanupInterval: ReturnType<typeof setInterval> | null; constructor(); /** 获取缓存 */ get(key: string): unknown; /** * 设置缓存 * @param ttlSeconds 默认 300 秒 */ set(key: string, value: unknown, ttlSeconds?: number): void; /** 删除缓存 */ delete(key: string): boolean; /** 清空所有缓存 */ clear(): void; /** 清理过期缓存 */ cleanupExpired(): void; /** 获取缓存统计信息 */ getStats(): { size: number; entries: string[]; }; /** 关闭缓存服务 */ shutdown(): void; } /** 缓存键生成器 */ export declare class CacheKeyBuilder { static candidate(id: string): string; static candidatesList(page: number, limit: number, status?: string): string; static recipe(id: string): string; static recipesList(page: number, limit: number, category?: string): string; static rule(id: string): string; static rulesList(page: number, limit: number, status?: string): string; static health(): string; static stats(): string; } export declare const cacheService: CacheService;