@bbc/http-transport-cache
Version:
Caching middleware
20 lines (14 loc) • 409 B
JavaScript
;
const bluebird = require('bluebird');
function applyTimeoutIfNeeded(pending, timeout) {
if (!timeout) return pending;
return bluebird
.resolve(pending)
.timeout(timeout, `Starting cache timed out after ${timeout}`);
}
async function startCacheConnection({ cache, timeout }) {
return applyTimeoutIfNeeded(cache.start(), timeout);
}
module.exports = {
startCacheConnection
};