blue-fish-redis
Version:
这是一个修复漏洞后的redis
32 lines (31 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisQueue = void 0;
const coa_echo_1 = require("coa-echo");
const sep = '^^';
class RedisQueue {
constructor(bin, name) {
const prefix = `${bin.config.prefix}-{aac-queue-${name}}-`;
this.keys = {
prefix,
pending: prefix + 'pending',
doing: prefix + 'doing',
doing_map: prefix + 'doing-map',
retrying: prefix + 'retrying',
};
this.bin = bin;
this.io = bin.io;
this.name = name;
}
// 推送新任务
async push(name, id, data) {
const job = name + sep + id + sep + JSON.stringify(data);
coa_echo_1.echo.grey('* Queue: push new job %s', job);
return await this.io.lpush(this.keys.pending, job);
}
// 定义一个新的推送者
definePusher(name) {
return async (id, data) => await this.push(name, id, data);
}
}
exports.RedisQueue = RedisQueue;