@sap/xssec
Version:
XS Advanced Container Security API for node.js
32 lines • 1.41 kB
TypeScript
export = ResponseCache;
/**
* Caches responses from an endpoint with different request parameters that are eagerly refreshed in the background
* when accessed shortly before expiration.
*/
declare class ResponseCache {
static get DEFAULT_EXPIRATION_TIME(): number;
static get DEFAULT_REFRESH_PERIOD(): number;
constructor({ expirationTime, refreshPeriod, endpointName }?: {
expirationTime?: number;
refreshPeriod?: number;
endpointName?: string;
});
/** @type {Map<string,ResponseReplica>} */
cache: Map<string, ResponseReplica>;
endpointName: string;
expirationTime: number;
refreshPeriod: number;
/**
* Returns an up-to-date response associated with the given key. If there is no replica yet for the key, caches a new replica under this key that
* uses the given request callback to fetch its responses.
* @param key cache key of response
* @param buildRequest callback that constructs a request function for fetching new responses if no replica exists yet for the key. The request function
* has to throw an Error with a statusCode and statusText if it fails to fetch the data.
*/
getOrRequest(key: any, buildRequest: any, { correlationId }: {
correlationId: any;
}): Promise<any>;
#private;
}
import ResponseReplica = require("./ResponseReplica");
//# sourceMappingURL=ResponseCache.d.ts.map