@metis-w/api-client
Version:
Modern TypeScript HTTP API client with dynamic routes, parameterized endpoints, interceptors, and advanced features
90 lines • 3.54 kB
TypeScript
/**
* Manages caching for dynamic routes, actions, and parameterized routes
* in the DynamicClient to improve performance and maintain stable references.
*/
export declare class CacheManager {
private routeCache;
private actionCache;
private parameterizedCache;
/**
* Gets a cached route by controller name
* @param controller - The controller name to get the cached route for
* @returns The cached route or undefined if not found
*/
getRoute(controller: string): unknown | undefined;
/**
* Sets a cached route for a controller
* @param controller - The controller name to set the route for
* @param route - The route to cache
*/
setRoute(controller: string, route: unknown): void;
/**
* Checks if a route is cached
* @param controller - The controller name to check
* @returns True if the route is cached, false otherwise
*/
hasRoute(controller: string): boolean;
/**
* Gets a cached action route by cache key
* @param cacheKey - The cache key to get the action route for
* @returns The cached action route or undefined if not found
*/
getActionRoute(cacheKey: string): Record<string, unknown> | undefined;
/**
* Sets a cached action route
* @param cacheKey - The cache key to set the action route for
* @param actionRoute - The action route to cache
*/
setActionRoute(cacheKey: string, actionRoute: Record<string, unknown>): void;
/**
* Checks if an action route is cached
* @param cacheKey - The cache key to check
* @returns True if the action route is cached, false otherwise
*/
hasActionRoute(cacheKey: string): boolean;
/**
* Gets a cached parameterized route by cache key
* @param cacheKey - The cache key to get the parameterized route for
* @returns The cached parameterized route or undefined if not found
*/
getParameterizedRoute(cacheKey: string): unknown | undefined;
/**
* Sets a cached parameterized route
* @param cacheKey - The cache key to set the parameterized route for
* @param paramRoute - The parameterized route to cache
*/
setParameterizedRoute(cacheKey: string, paramRoute: unknown): void;
/**
* Checks if a parameterized route is cached
* @param cacheKey - The cache key to check
* @returns True if the parameterized route is cached, false otherwise
*/
hasParameterizedRoute(cacheKey: string): boolean;
/**
* Generates cache key for action routes
* @param controller - The controller name to generate the cache key for
* @returns The generated cache key
*/
static generateActionCacheKey(controller: string): string;
/**
* Generates cache key for parameterized routes
* @param controller - The controller name to generate the cache key for
* @param id - The ID to include in the cache key
*/
static generateParameterizedCacheKey(controller: string, id: string | number): string;
/**
* This method clears the route, action, and parameterized caches.
* It is useful for resetting the cache state, for example, when the API structure changes
*/
clearProxyCache(): void;
/**
* Gets cache statistics
* @returns An object containing the number of cached routes, actions, and parameterized routes
*/
getStats(): {
routes: number;
actions: number;
parameterized: number;
};
}
//# sourceMappingURL=cache-manager.d.ts.map