redis-smq-common
Version:
Provides essential components and utilities shared across RedisSMQ packages.
145 lines • 3.56 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();
}
get(key) {
this.multi.get(key);
return this;
}
hget(key, field) {
this.multi.hGet(key, field);
return this;
}
smembers(key) {
this.multi.sMembers(key);
return this;
}
hgetall(key) {
this.multi.hGetAll(key);
return this;
}
zcard(key) {
this.multi.zCard(key);
return this;
}
scard(key) {
this.multi.sCard(key);
return this;
}
llen(key) {
this.multi.lLen(key);
return this;
}
zscore(key, member) {
this.multi.zScore(key, member);
return this;
}
set(key, value, options) {
this.multi.set(key, value, Object.assign(Object.assign({}, (options.expire
? { [options.expire.mode]: options.expire.value }
: {})), (options.exists ? { [options.exists]: true } : {})));
return this;
}
incr(key) {
this.multi.incr(key);
return this;
}
decr(key) {
this.multi.decr(key);
return this;
}
incrby(key, increment) {
this.multi.incrBy(key, increment);
return this;
}
decrby(key, decrement) {
this.multi.decrBy(key, decrement);
return this;
}
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