cache-or-req
A very simple cache for request-promise operations, primary goal is to return always a value after the first real fetch. The library tried to re-fetch after TTL is reached but returns immediately, the next request within the TTL time will return the updated result. This library should primarily be used for accessing configuration via APIs and ensure that services get always some kind of configuration.
This library is a very simple wrapper around request-promise (https://www.npmjs.com/package/request-promise) basic implementation request().then().catch()
Usage
const CacheOrReq = require('./CacheOrReq');
let cacheOrReq = new CacheOrReq(
1000,
1000 * 60 * 60
);
cacheOrReq.get({
url: TEST_URL,
method: 'GET'
}).then((data) => {
}).catch((error) => {
});
cacheOrReq.clearCache();