redis-smq-common
Version:
RedisSMQ Common Library provides many components that are mainly used by RedisSMQ and RedisSMQ Monitor.
88 lines • 2.15 kB
JavaScript
import { WatchError, } from '@redis/client';
import { WatchedKeysChangedError } from '../../errors/index.js';
export class NodeRedisClientMulti {
multi;
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 WatchError)
cb(new WatchedKeysChangedError());
else
cb(err);
});
}
}
//# sourceMappingURL=node-redis-client-multi.js.map