UNPKG

pms-analysis-reports-mcp-server

Version:

PMS analysis reports server handling maintenance reports, equipment analysis, compliance tracking, and performance metrics with ERP access for data extraction

90 lines (89 loc) 2.28 kB
import { BaseService, ServiceConfig, ServiceResponse } from "./base-service.js"; export interface CacheItem<T = any> { data: T; timestamp: number; ttl: number; hits: number; } export interface CacheConfig extends ServiceConfig { maxSize?: number; defaultTtl?: number; cleanupInterval?: number; } export interface CacheStats { size: number; maxSize: number; hits: number; misses: number; hitRate: number; evictions: number; } export declare class CacheService extends BaseService { private cache; private stats; private cleanupTimer?; private readonly maxSize; private readonly defaultTtl; private readonly cleanupInterval; constructor(config?: CacheConfig); /** * Get item from cache */ get<T = any>(key: string): Promise<ServiceResponse<T | null>>; /** * Set item in cache */ set<T = any>(key: string, data: T, ttl?: number): Promise<ServiceResponse<boolean>>; /** * Delete item from cache */ delete(key: string): Promise<ServiceResponse<boolean>>; /** * Check if key exists in cache */ has(key: string): Promise<ServiceResponse<boolean>>; /** * Get or set pattern - get from cache, or compute and cache if not found */ getOrSet<T = any>(key: string, computeFn: () => Promise<T>, ttl?: number): Promise<ServiceResponse<T | null>>; /** * Clear all cache entries */ clear(): Promise<ServiceResponse<boolean>>; /** * Get cache statistics */ getStats(): CacheStats; /** * Evict expired entries */ cleanupExpired(): number; /** * Evict least recently used item */ private evictLeastRecentlyUsed; /** * Start automatic cleanup timer */ private startCleanupTimer; /** * Stop cleanup timer */ stopCleanup(): void; /** * Health check implementation */ healthCheck(): Promise<boolean>; /** * Generate cache key from object */ static generateKey(prefix: string, params: Record<string, any>): string; /** * Simple hash function for cache keys */ private static simpleHash; /** * Cleanup on service shutdown */ shutdown(): Promise<void>; }