@iota-big3/sdk-gateway
Version:
Universal API Gateway with protocol translation, intelligent routing, rate limiting, health checking, and caching
98 lines • 2.4 kB
TypeScript
/**
* @iota-big3/sdk-gateway
* Cache Manager - Response caching with multiple strategies
* Phase 2g Implementation
*/
import type { Result } from '@iota-big3/sdk-patterns';
import { EventEmitter } from 'events';
import { CacheConfig, CacheEntry, CacheStats, GatewayRequest, GatewayResponse } from '../types/gateway-types';
/**
* Cache manager with support for multiple strategies
*/
export declare class CacheManager extends EventEmitter {
private config;
private store;
private enabled;
private entries;
private accessOrder;
private stats;
private tagIndex;
constructor(config: CacheConfig);
/**
* Get value from cache
*/
get<T = unknown>(key: string): Promise<T | null>;
/**
* Set value in cache
*/
set<T = unknown>(key: string, value: T, ttl?: number, tags?: string[]): Promise<void>;
/**
* Delete from cache
*/
deleteAsync(key: string): Promise<Result<5297, Error>>;
/**
* Clear entire cache
*/
clearAsync(): Promise<void>;
/**
* Invalidate by pattern
*/
invalidatePatternAsync(pattern: string): Promise<void>;
/**
* Invalidate by tag
*/
invalidateTagAsync(tag: string): Promise<void>;
/**
* Get cache entry (for testing)
*/
getEntryAsync(key: string): Promise<CacheEntry | undefined>;
/**
* Generate cache key from request
*/
generateKey(request: Partial<GatewayRequest>): string;
/**
* Default key generator
*/
private defaultKeyGenerator;
/**
* Check if request should be cached
*/
shouldCache(request: Partial<GatewayRequest>): boolean;
/**
* Check if response should be cached
*/
shouldCacheResponse(response: Partial<GatewayResponse>): boolean;
/**
* Evict entries based on strategy
*/
private evictAsync;
/**
* Update hit rate
*/
private updateHitRate;
/**
* Get cache statistics
*/
getStats(): CacheStats;
/**
* Enable caching
*/
enable(): void;
/**
* Disable caching
*/
disable(): void;
/**
* Check if caching is enabled
*/
isEnabled(): boolean;
/**
* Clean up expired entries
*/
cleanupAsync(): Promise<void>;
/**
* Destroy cache manager
*/
destroy(): void;
}
//# sourceMappingURL=cache-manager.d.ts.map