UNPKG

@anglr/rest

Version:

Angular module representing rest services

44 lines 2.02 kB
import { HttpRequest, HttpResponse } from '@angular/common/http'; import { Dictionary } from '@jscrpt/common'; import { AdvancedCacheItem, RestDateApi } from '../../interfaces'; import { AdvancedCacheItemOptions } from '../../misc/types'; import * as i0 from "@angular/core"; /** * Allows advanced caching of http responses */ export declare class AdvancedCacheService<TDate = unknown> { protected restDateApi: RestDateApi; /** * Instance of cache and its data */ protected cache: Dictionary<Dictionary<AdvancedCacheItem<TDate>>>; constructor(restDateApi: RestDateApi); /** * Clears cache either for specified key, or whole cache * @param key - Name of cache to be cleared, if not provided all cached items will be cleared */ clearCache(key?: string): void; /** * Adds response to advanced cache * @param key - Key under which will be cached item stored * @param request - Request for which will be response added * @param response - Response to be cached * @param config - Configuration for cached response */ add(key: string, request: HttpRequest<unknown>, response: HttpResponse<unknown>, config: AdvancedCacheItemOptions<TDate>): HttpResponse<unknown>; /** * Gets http response from cache, or null if it does not exists * @param key - Key which represents cached item * @param request - Request for which will be response returned */ get(key: string, request: HttpRequest<unknown>): HttpResponse<unknown> | null; /** * Updates existing cache items, if not exists it does nothing * @param key - Key which represents cached items * @param config - Config to be applied to existing cache items */ updateCache(key: string, config: AdvancedCacheItemOptions<TDate>): void; static ɵfac: i0.ɵɵFactoryDeclaration<AdvancedCacheService<any>, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AdvancedCacheService<any>>; } //# sourceMappingURL=advancedCache.service.d.ts.map