@apify/actors-mcp-server
Version:
Model Context Protocol Server for Apify
35 lines • 1.22 kB
TypeScript
/**
* LRU cache with TTL (time-to-live) for storing entries.
*
* This class wraps an LRU cache and adds a time-to-live (TTL) expiration to each entry.
* When an entry is accessed, it is checked for expiration and removed if expired.
*
* Usage:
* ```typescript
* const cache = new TTLLRUCache<string>(100, 60); // 100 items, 60 seconds TTL
* cache.set('key', 'value');
* const value = cache.get('key');
* ```
*/
export declare class TTLLRUCache<T> {
private readonly cache;
private readonly ttlMillis;
/**
* @param maxLength Maximum number of items in the cache (LRU eviction)
* @param ttlSecs Time-to-live for each entry, in seconds
*/
constructor(maxLength: number, ttlSecs: number);
/**
* Set a value in the cache with the given key. If the key exists, it is updated and TTL is reset.
* @param key Cache key
* @param value Value to store
*/
set(key: string, value: T): void;
/**
* Get a value from the cache by key. Returns null if not found or expired.
* @param key Cache key
* @returns The value if present and not expired, otherwise null
*/
get(key: string): T | null;
}
//# sourceMappingURL=ttl-lru.d.ts.map