@kth/cortina-block
Version:
Node.js module for fetching Cortina blocks and optionally cache using Redis.
21 lines (20 loc) • 591 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRedisItem = getRedisItem;
exports.setRedisItem = setRedisItem;
function getRedisItem(redis, redisKey, lang) {
return redis.hgetallAsync(redisKey + lang);
}
/**
* Wrap Redis set call in a Promise.
* @param config
* @param blocks
* @returns {Promise}
* @private
*/
function setRedisItem(redis, redisKey, redisExpire, lang, blocks) {
return redis
.hmsetAsync(redisKey + lang, blocks)
.then(() => redis.expireAsync(redisKey + lang, redisExpire))
.then(() => blocks);
}