Skip to content

Commit 027ff69

Browse files
committed
Make redis timeout configurable
1 parent 9da1fc5 commit 027ff69

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ addDefaults(config, {
134134
},
135135
disableOfflineQueue: true,
136136
expiryTime: 24 * 60 * 60,
137+
getTimeout: 40
137138
}
138139
});
139140
loadFromEnv(config);

src/types/config.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as redis from "redis";
44
interface RedisConfig extends redis.RedisClientOptions {
55
enabled: boolean;
66
expiryTime: number;
7+
getTimeout: number;
78
}
89

910
export interface CustomPostgresConfig extends PoolConfig {

src/utils/redis.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ if (config.redis?.enabled) {
3131
client.connect();
3232
exportClient = client as RedisSB;
3333

34-
const timeoutDuration = 40;
3534
const get = client.get.bind(client);
3635
exportClient.get = (key) => new Promise((resolve, reject) => {
37-
const timeout = setTimeout(() => reject(), timeoutDuration);
36+
const timeout = setTimeout(() => reject(), config.redis.getTimeout);
3837
get(key).then((reply) => {
3938
clearTimeout(timeout);
4039
resolve(reply);

0 commit comments

Comments
 (0)