mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Make redis timeout configurable
This commit is contained in:
parent
9da1fc523a
commit
027ff694a0
3 changed files with 3 additions and 2 deletions
|
@ -134,6 +134,7 @@ addDefaults(config, {
|
||||||
},
|
},
|
||||||
disableOfflineQueue: true,
|
disableOfflineQueue: true,
|
||||||
expiryTime: 24 * 60 * 60,
|
expiryTime: 24 * 60 * 60,
|
||||||
|
getTimeout: 40
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
loadFromEnv(config);
|
loadFromEnv(config);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as redis from "redis";
|
||||||
interface RedisConfig extends redis.RedisClientOptions {
|
interface RedisConfig extends redis.RedisClientOptions {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
expiryTime: number;
|
expiryTime: number;
|
||||||
|
getTimeout: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CustomPostgresConfig extends PoolConfig {
|
export interface CustomPostgresConfig extends PoolConfig {
|
||||||
|
|
|
@ -31,10 +31,9 @@ if (config.redis?.enabled) {
|
||||||
client.connect();
|
client.connect();
|
||||||
exportClient = client as RedisSB;
|
exportClient = client as RedisSB;
|
||||||
|
|
||||||
const timeoutDuration = 40;
|
|
||||||
const get = client.get.bind(client);
|
const get = client.get.bind(client);
|
||||||
exportClient.get = (key) => new Promise((resolve, reject) => {
|
exportClient.get = (key) => new Promise((resolve, reject) => {
|
||||||
const timeout = setTimeout(() => reject(), timeoutDuration);
|
const timeout = setTimeout(() => reject(), config.redis.getTimeout);
|
||||||
get(key).then((reply) => {
|
get(key).then((reply) => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
resolve(reply);
|
resolve(reply);
|
||||||
|
|
Loading…
Reference in a new issue