Clear redis timeouts

This commit is contained in:
Ajay
2022-03-04 19:22:01 -05:00
parent 6507a3a68d
commit b182945274

View File

@@ -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 })));