utils.js
469 Bytes
const redis = global.yoho.redis;
async function* createAsyncKeyIterable(preKey) {
let page = 1;
let isExists = true;
while (isExists) {
let key = `${preKey}${page}`;
let result = await redis.existsAsync(key);
result = Number(result);
if (result === 1) {
yield { page, key };
page++;
} else {
isExists = false;
}
}
}
module.exports = {
createAsyncKeyIterable
};