mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
88 lines (87 loc) • 2.18 kB
TypeScript
/**
* Cache service for API responses
*/
export declare class CacheService {
private cache;
private enabled;
private static instances;
private static cleanupHandlerInstalled;
private operationLock;
/**
* Creates a new cache service
* @param ttl Default TTL in seconds (default: 3600)
* @param enabled Whether caching is enabled (default: true)
*/
constructor(ttl?: number, enabled?: boolean);
/**
* Gets a value from the cache
* @param key Cache key
* @returns The cached value or undefined if not found
*/
get<T>(key: string): T | undefined;
/**
* Sets a value in the cache
* @param key Cache key
* @param value Value to cache
* @param ttl TTL in seconds (optional, uses default if not specified)
*/
set<T>(key: string, value: T, ttl?: number): void;
/**
* Removes a value from the cache
* @param key Cache key
*/
del(key: string): void;
/**
* Clears all cache entries
*/
clear(): void;
/**
* Enables or disables the cache
* @param enabled Whether the cache should be enabled
*/
setEnabled(enabled: boolean): void;
/**
* Returns whether the cache is enabled
*/
isEnabled(): boolean;
/**
* Checks if a key exists in the cache
* @param key Cache key
* @returns True if the key exists, false otherwise
*/
has(key: string): boolean;
/**
* Removes a value from the cache (alias for del)
* @param key Cache key
*/
delete(key: string): void;
/**
* Gets cache statistics
* @returns Cache statistics
*/
getStats(): {
hits: number;
misses: number;
keys: number;
};
/**
* Sets a new default TTL
* @param ttl New TTL in seconds
*/
setTtl(ttl: number): void;
private safeTtlUpdate;
/**
* Cleanup this cache instance
*/
cleanup(): void;
/**
* Install process cleanup handlers (called once)
*/
private static installCleanupHandlers;
/**
* Get cleanup statistics
*/
static getStats(): {
instances: number;
};
}