Only use redis timeout when db not under load

This commit is contained in:
Ajay
2024-01-18 09:22:00 -05:00
parent d607d8b179
commit c9f7275942
6 changed files with 15 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ export interface IDatabase {
prepare(type: QueryType, query: string, params?: any[], options?: QueryOption): Promise<any | any[] | void>;
highLoad(): boolean;
shouldUseRedisTimeout(): boolean;
}
export type QueryType = "get" | "all" | "run";

View File

@@ -283,4 +283,8 @@ export class Postgres implements IDatabase {
highLoad() {
return this.activePostgresRequests > this.config.postgres.highLoadThreshold;
}
shouldUseRedisTimeout() {
return this.activePostgresRequests < this.config.postgres.redisTimeoutThreshold;
}
}

View File

@@ -108,6 +108,10 @@ export class Sqlite implements IDatabase {
highLoad() {
return false;
}
shouldUseRedisTimeout() {
return false;
}
}
export interface SqliteConfig {