refactor: remove promisify from redis, ioredis supports promises nati… (#9728)

* refactor: remove promisify from redis, ioredis supports promises natively

* refactor: remove unused util
This commit is contained in:
Barış Soner Uşaklı
2021-08-21 23:31:31 -04:00
committed by GitHub
parent d44e3a8ecf
commit 6659e95a4a
9 changed files with 53 additions and 126 deletions

View File

@@ -30,7 +30,7 @@ module.exports = function (module) {
key.forEach(k => batch.hmset(k, data));
await helpers.execBatch(batch);
} else {
await module.client.async.hmset(key, data);
await module.client.hmset(key, data);
}
cache.del(key);
@@ -55,7 +55,7 @@ module.exports = function (module) {
key.forEach(k => batch.hset(k, field, value));
await helpers.execBatch(batch);
} else {
await module.client.async.hset(key, field, value);
await module.client.hset(key, field, value);
}
cache.del(key);
@@ -83,7 +83,7 @@ module.exports = function (module) {
if (cachedData[key]) {
return cachedData[key].hasOwnProperty(field) ? cachedData[key][field] : null;
}
return await module.client.async.hget(key, String(field));
return await module.client.hget(key, String(field));
};
module.getObjectFields = async function (key, fields) {
@@ -108,7 +108,7 @@ module.exports = function (module) {
unCachedKeys.forEach(k => batch.hgetall(k));
data = await helpers.execBatch(batch);
} else if (unCachedKeys.length === 1) {
data = [await module.client.async.hgetall(unCachedKeys[0])];
data = [await module.client.hgetall(unCachedKeys[0])];
}
// convert empty objects into null for back-compat with node_redis
@@ -138,15 +138,15 @@ module.exports = function (module) {
};
module.getObjectKeys = async function (key) {
return await module.client.async.hkeys(key);
return await module.client.hkeys(key);
};
module.getObjectValues = async function (key) {
return await module.client.async.hvals(key);
return await module.client.hvals(key);
};
module.isObjectField = async function (key, field) {
const exists = await module.client.async.hexists(key, field);
const exists = await module.client.hexists(key, field);
return exists === 1;
};
@@ -161,7 +161,7 @@ module.exports = function (module) {
if (key === undefined || key === null || field === undefined || field === null) {
return;
}
await module.client.async.hdel(key, field);
await module.client.hdel(key, field);
cache.del(key);
};
@@ -178,7 +178,7 @@ module.exports = function (module) {
key.forEach(k => batch.hdel(k, fields));
await helpers.execBatch(batch);
} else {
await module.client.async.hdel(key, fields);
await module.client.hdel(key, fields);
}
cache.del(key);
@@ -203,7 +203,7 @@ module.exports = function (module) {
key.forEach(k => batch.hincrby(k, field, value));
result = await helpers.execBatch(batch);
} else {
result = await module.client.async.hincrby(key, field, value);
result = await module.client.hincrby(key, field, value);
}
cache.del(key);
return Array.isArray(result) ? result.map(value => parseInt(value, 10)) : parseInt(result, 10);