redis-smq-common
Version:
RedisSMQ Common Library provides many components that are mainly used by RedisSMQ and RedisSMQ Monitor.
91 lines • 2.31 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeRedisClientMulti = void 0;
const client_1 = require("@redis/client");
const index_js_1 = require("../../errors/index.js");
class NodeRedisClientMulti {
constructor(client) {
this.multi = client.multi();
}
lrem(key, count, element) {
this.multi.lRem(key, count, element);
return this;
}
lpop(key) {
this.multi.lPop(key);
return this;
}
lpush(key, element) {
this.multi.lPush(key, element);
return this;
}
ltrim(key, start, stop) {
this.multi.lTrim(key, start, stop);
return this;
}
rpop(key) {
this.multi.rPop(key);
return this;
}
rpush(key, element) {
this.multi.rPush(key, element);
return this;
}
zadd(key, score, element) {
this.multi.zAdd(key, { score, value: element });
return this;
}
zrem(key, element) {
this.multi.zRem(key, element);
return this;
}
sadd(key, element) {
this.multi.sAdd(key, element);
return this;
}
srem(key, element) {
this.multi.sRem(key, element);
return this;
}
hset(key, field, value) {
this.multi.hSet(key, field, value);
return this;
}
hdel(key, field) {
this.multi.hDel(key, field);
return this;
}
hincrby(key, field, by) {
this.multi.hIncrBy(key, field, by);
return this;
}
pexpire(key, millis) {
this.multi.pExpire(key, millis);
return this;
}
expire(key, secs) {
this.multi.expire(key, secs);
return this;
}
rpoplpush(source, destination) {
this.multi.rPopLPush(source, destination);
return this;
}
del(key) {
this.multi.del(key);
return this;
}
exec(cb) {
this.multi
.exec()
.then((reply) => cb(null, reply))
.catch((err) => {
if (err instanceof client_1.WatchError)
cb(new index_js_1.WatchedKeysChangedError());
else
cb(err);
});
}
}
exports.NodeRedisClientMulti = NodeRedisClientMulti;
//# sourceMappingURL=node-redis-client-multi.js.map