Don't fallback to db when too many redis connections

This commit is contained in:
Ajay
2024-01-15 14:07:34 -05:00
parent 7aaf000d99
commit d607d8b179
2 changed files with 9 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import redis from "../utils/redis";
import redis, { TooManyActiveConnectionsError } from "../utils/redis";
import { Logger } from "../utils/logger";
import { skipSegmentsHashKey, skipSegmentsKey, reputationKey, ratingHashKey, skipSegmentGroupsKey, userFeatureKey, videoLabelsKey, videoLabelsHashKey, brandingHashKey, brandingKey } from "./redisKeys";
import { Service, VideoID, VideoIDHash } from "../types/segments.model";
@@ -13,7 +13,11 @@ async function get<T>(fetchFromDB: () => Promise<T>, key: string): Promise<T> {
return JSON.parse(reply);
}
} catch (e) { } //eslint-disable-line no-empty
} catch (e) {
if (e instanceof TooManyActiveConnectionsError) {
throw e;
}
}
const data = await fetchFromDB();