Stop spamming redis if it slows down

This commit is contained in:
Ajay
2022-10-29 21:03:34 -04:00
parent 96db571a5e
commit 571230db56
3 changed files with 9 additions and 1 deletions

View File

@@ -41,7 +41,13 @@ if (config.redis?.enabled) {
const get = client.get.bind(client);
const getRead = readClient?.get?.bind(readClient);
exportClient.get = (key) => new Promise((resolve, reject) => {
if (activeRequests > config.redis.maxConnections) {
reject("Too many active requests");
return;
}
activeRequests++;
const timeout = config.redis.getTimeout ? setTimeout(() => reject(), config.redis.getTimeout) : null;
const chosenGet = pickChoice(get, getRead);
chosenGet(key).then((reply) => {