mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 14:37:17 +03:00
Stop spamming redis if it slows down
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user