mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 20:17:02 +03:00
Clear redis timeouts
This commit is contained in:
@@ -33,10 +33,13 @@ if (config.redis) {
|
||||
const client = redis.createClient(config.redis);
|
||||
exportObject = client;
|
||||
|
||||
const timeout = 200;
|
||||
const timeoutDuration = 200;
|
||||
exportObject.getAsync = (key) => new Promise((resolve) => {
|
||||
client.get(key, (err, reply) => resolve({ err, reply }));
|
||||
setTimeout(() => resolve({ err: null, reply: undefined }), timeout);
|
||||
const timeout = setTimeout(() => resolve({ err: null, reply: undefined }), timeoutDuration);
|
||||
client.get(key, (err, reply) => {
|
||||
clearTimeout(timeout);
|
||||
resolve({ err, reply });
|
||||
});
|
||||
});
|
||||
exportObject.setAsync = (key, value) => new Promise((resolve) => client.set(key, value, (err, reply) => resolve({ err, reply })));
|
||||
exportObject.setAsyncEx = (key, value, seconds) => new Promise((resolve) => client.setex(key, seconds, value, (err, reply) => resolve({ err, reply })));
|
||||
|
||||
Reference in New Issue
Block a user