hikma-engine
Version:
Code Knowledge Graph Indexer - A sophisticated TypeScript-based indexer that transforms Git repositories into multi-dimensional knowledge stores for AI agents
78 lines • 1.87 kB
TypeScript
/**
* @file In-memory cache service for API search results.
* Provides LRU caching with TTL support without external dependencies.
*/
/**
* Cache configuration interface.
*/
interface CacheConfig {
maxSize: number;
defaultTTL: number;
}
/**
* In-memory cache service with LRU eviction and TTL support.
*/
export declare class InMemoryCacheService {
private cache;
private accessOrder;
private config;
constructor(config?: Partial<CacheConfig>);
/**
* Sets a value in the cache with optional TTL.
*/
set<T>(key: string, value: T, ttl?: number): void;
/**
* Gets a value from the cache.
*/
get<T>(key: string): T | null;
/**
* Deletes a value from the cache.
*/
delete(key: string): boolean;
/**
* Clears all cache entries.
*/
clear(): void;
/**
* Gets cache statistics.
*/
getStats(): {
size: number;
maxSize: number;
hitRate?: number;
oldestEntry?: {
key: string;
age: number;
};
};
/**
* Generates a cache key for search operations.
*/
generateSearchKey(searchType: string, query: string, options?: Record<string, any>): string;
/**
* Evicts least recently used entries.
*/
private evictLRU;
/**
* Updates access order for LRU tracking.
*/
private updateAccessOrder;
/**
* Removes key from access order array.
*/
private removeFromAccessOrder;
/**
* Simple hash function for long cache keys.
*/
private simpleHash;
/**
* Cleanup expired entries (can be called periodically).
*/
cleanup(): number;
}
/**
* Default cache instance for the API.
*/
export declare const defaultCacheService: InMemoryCacheService;
export {};
//# sourceMappingURL=cache-service.d.ts.map