mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 22:47:12 +03:00
Fix redis set limiting
This commit is contained in:
@@ -86,7 +86,7 @@ if (config.redis?.enabled) {
|
|||||||
const setFun = <T extends Array<any>>(func: (...args: T) => Promise<string>, params: T): Promise<string> =>
|
const setFun = <T extends Array<any>>(func: (...args: T) => Promise<string>, params: T): Promise<string> =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
if (config.redis.maxWriteConnections && activeRequests > config.redis.maxWriteConnections) {
|
if (config.redis.maxWriteConnections && activeRequests > config.redis.maxWriteConnections) {
|
||||||
reject("Too many active requests");
|
reject("Too many active requests to write");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +108,10 @@ if (config.redis?.enabled) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// exportClient.set = (key, value) => setFun(client.set.bind(client), [key, value]);
|
const set = client.set.bind(client);
|
||||||
// exportClient.setEx = (key, seconds, value) => setFun(client.setEx.bind(client), [key, seconds, value]);
|
const setEx = client.setEx.bind(client);
|
||||||
|
exportClient.set = (key, value) => setFun(set, [key, value]);
|
||||||
|
exportClient.setEx = (key, seconds, value) => setFun(setEx, [key, seconds, value]);
|
||||||
exportClient.increment = (key) => new Promise((resolve, reject) =>
|
exportClient.increment = (key) => new Promise((resolve, reject) =>
|
||||||
void client.multi()
|
void client.multi()
|
||||||
.incr(key)
|
.incr(key)
|
||||||
|
|||||||
Reference in New Issue
Block a user