UNPKG

react-http-fetch

Version:

An http library for React JS built on top of native JS fetch

48 lines (47 loc) 1.52 kB
import { HttpRequest } from '../client'; import { HttpCacheStorePrefixDecorator } from './prefix-decorator'; export declare class HttpCacheService { private prefixedStore; constructor(store: HttpCacheStorePrefixDecorator); /** * Gets the unique key used as idenitifier to store * a cached response for the given http request. */ private getRequestIdentifier; /** * Tells if a cached entry is expired. */ private isEntryExpired; /** * Gets the cached entry associated with the request. */ private getEntry; /** * Removes a cached entry. */ private removeEntry; /** * Determines if for the given request is available a cached response. */ has<HttpRequestBodyT>(request: HttpRequest<HttpRequestBodyT>): boolean; /** * Tells if the cached request is expired or not. */ isExpired<HttpRequestBodyT>(request: HttpRequest<HttpRequestBodyT>): boolean; /** * Gets the cached entry in the map for the given request. */ get<HttpResponseT, HttpRequestBodyT>(request: HttpRequest<HttpRequestBodyT>): HttpResponseT | undefined; /** * Puts a new cached response for the given request. */ put<HttpResponseT, HttpRequestBodyT>(request: HttpRequest<HttpRequestBodyT>, response: HttpResponseT): void; /** * Founds all expired entry and deletes them from the cache. */ prune(): void; /** * Flush the cache by removing all entries. */ flush(): void; }