mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-03-24 14:57:40 +03:00
Only use redis timeout when db not under load
This commit is contained in:
@@ -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";
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,10 @@ export class Sqlite implements IDatabase {
|
||||
highLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
shouldUseRedisTimeout() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export interface SqliteConfig {
|
||||
|
||||
Reference in New Issue
Block a user