mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-21 07:50:37 +01:00
feat: test psql without defineProperty (#7815)
* feat: test psql without defineProperty * feat: refactor psql remove .bind calls, use module.pool.query directly move requires to top of file move promisify to bottom so .init etc are promisified * feat: mongodb move requires to bottom * feat: redis
This commit is contained in:
committed by
GitHub
parent
52a2e5d61d
commit
af1f7249a7
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (redisClient, module) {
|
||||
module.exports = function (module) {
|
||||
var helpers = require('./helpers');
|
||||
|
||||
module.setAdd = async function (key, value) {
|
||||
@@ -10,14 +10,14 @@ module.exports = function (redisClient, module) {
|
||||
if (!value.length) {
|
||||
return;
|
||||
}
|
||||
await redisClient.async.sadd(key, value);
|
||||
await module.client.async.sadd(key, value);
|
||||
};
|
||||
|
||||
module.setsAdd = async function (keys, value) {
|
||||
if (!Array.isArray(keys) || !keys.length) {
|
||||
return;
|
||||
}
|
||||
const batch = redisClient.batch();
|
||||
const batch = module.client.batch();
|
||||
keys.forEach(k => batch.sadd(String(k), String(value)));
|
||||
await helpers.execBatch(batch);
|
||||
};
|
||||
@@ -30,58 +30,58 @@ module.exports = function (redisClient, module) {
|
||||
key = [key];
|
||||
}
|
||||
|
||||
var batch = redisClient.batch();
|
||||
var batch = module.client.batch();
|
||||
key.forEach(k => batch.srem(String(k), value));
|
||||
await helpers.execBatch(batch);
|
||||
};
|
||||
|
||||
module.setsRemove = async function (keys, value) {
|
||||
var batch = redisClient.batch();
|
||||
var batch = module.client.batch();
|
||||
keys.forEach(k => batch.srem(String(k), value));
|
||||
await helpers.execBatch(batch);
|
||||
};
|
||||
|
||||
module.isSetMember = async function (key, value) {
|
||||
const result = await redisClient.async.sismember(key, value);
|
||||
const result = await module.client.async.sismember(key, value);
|
||||
return result === 1;
|
||||
};
|
||||
|
||||
module.isSetMembers = async function (key, values) {
|
||||
const batch = redisClient.batch();
|
||||
const batch = module.client.batch();
|
||||
values.forEach(v => batch.sismember(String(key), String(v)));
|
||||
const results = await helpers.execBatch(batch);
|
||||
return results ? helpers.resultsToBool(results) : null;
|
||||
};
|
||||
|
||||
module.isMemberOfSets = async function (sets, value) {
|
||||
const batch = redisClient.batch();
|
||||
const batch = module.client.batch();
|
||||
sets.forEach(s => batch.sismember(String(s), String(value)));
|
||||
const results = await helpers.execBatch(batch);
|
||||
return results ? helpers.resultsToBool(results) : null;
|
||||
};
|
||||
|
||||
module.getSetMembers = async function (key) {
|
||||
return await redisClient.async.smembers(key);
|
||||
return await module.client.async.smembers(key);
|
||||
};
|
||||
|
||||
module.getSetsMembers = async function (keys) {
|
||||
const batch = redisClient.batch();
|
||||
const batch = module.client.batch();
|
||||
keys.forEach(k => batch.smembers(String(k)));
|
||||
return await helpers.execBatch(batch);
|
||||
};
|
||||
|
||||
module.setCount = async function (key) {
|
||||
return await redisClient.async.scard(key);
|
||||
return await module.client.async.scard(key);
|
||||
};
|
||||
|
||||
module.setsCount = async function (keys) {
|
||||
const batch = redisClient.batch();
|
||||
const batch = module.client.batch();
|
||||
keys.forEach(k => batch.scard(String(k)));
|
||||
return await helpers.execBatch(batch);
|
||||
};
|
||||
|
||||
module.setRemoveRandom = async function (key) {
|
||||
return await redisClient.async.spop(key);
|
||||
return await module.client.async.spop(key);
|
||||
};
|
||||
|
||||
return module;
|
||||
|
||||
Reference in New Issue
Block a user