@zxkane/quip-mcp-server
Version:
MCP server for interacting with Quip spreadsheets
79 lines (78 loc) • 2.31 kB
TypeScript
/**
* Cache implementation for the Quip MCP Server
*/
/**
* Simple in-memory cache with expiration
*/
export declare class Cache<T> {
private entries;
private defaultTtl;
private maxEntries;
/**
* Create a new cache
*
* @param defaultTtl Default time-to-live in milliseconds (default: 5 minutes)
* @param maxEntries Maximum number of entries to store (default: 100)
*/
constructor(defaultTtl?: number, maxEntries?: number);
/**
* Get a value from the cache
*
* @param key Cache key
* @returns Cached value or undefined if not found or expired
*/
get(key: string): T | undefined;
/**
* Set a value in the cache
*
* @param key Cache key
* @param value Value to cache
* @param ttl Time-to-live in milliseconds (default: use constructor value)
*/
set(key: string, value: T, ttl?: number): void;
/**
* Check if a key exists in the cache and is not expired
*
* @param key Cache key
* @returns True if the key exists and is not expired
*/
has(key: string): boolean;
/**
* Delete a key from the cache
*
* @param key Cache key
* @returns True if the key was deleted, false if it didn't exist
*/
delete(key: string): boolean;
/**
* Clear all entries from the cache
*/
clear(): void;
/**
* Get the number of entries in the cache
*
* @returns Number of entries
*/
size(): number;
/**
* Remove all expired entries from the cache
*
* @returns Number of entries removed
*/
prune(): number;
/**
* Get or set a value in the cache
*
* If the key exists and is not expired, returns the cached value.
* Otherwise, calls the factory function to generate a new value,
* stores it in the cache, and returns it.
*
* @param key Cache key
* @param factory Function to generate the value if not in cache
* @param ttl Time-to-live in milliseconds (default: use constructor value)
* @returns The cached or newly generated value
*/
getOrSet(key: string, factory: () => Promise<T>, ttl?: number): Promise<T>;
}
export declare const csvCache: Cache<string>;
export declare const metadataCache: Cache<Record<string, any>>;