diff --git a/src/routes/getVideoLabel.ts b/src/routes/getVideoLabel.ts index 29a897a..904ac47 100644 --- a/src/routes/getVideoLabel.ts +++ b/src/routes/getVideoLabel.ts @@ -81,7 +81,7 @@ async function getSegmentsFromDBByHash(hashedVideoIDPrefix: VideoIDHash, service [`${hashedVideoIDPrefix}%`, service] ) as Promise; - if (hashedVideoIDPrefix.length === 3) { + if (hashedVideoIDPrefix.length === 3 || hashedVideoIDPrefix.length === 4) { return await QueryCacher.get(fetchFromDB, videoLabelsHashKey(hashedVideoIDPrefix, service)); } diff --git a/src/utils/redisKeys.ts b/src/utils/redisKeys.ts index ce8e1d1..b6742df 100644 --- a/src/utils/redisKeys.ts +++ b/src/utils/redisKeys.ts @@ -58,10 +58,9 @@ export const videoLabelsKey = (videoID: VideoID, service: Service): string => `labels.v2.${service}.videoID.${videoID}`; export function videoLabelsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string { - hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 3) as VideoIDHash; - if (hashedVideoIDPrefix.length !== 3) Logger.warn(`Redis video labels hash-prefix key is not length 3! ${hashedVideoIDPrefix}`); + const length = hashedVideoIDPrefix.length; - return `labels.v1.${service}.${hashedVideoIDPrefix}`; + return `labels.v1.${length}.${service}.${hashedVideoIDPrefix}`; } export function userFeatureKey (userID: HashedUserID, feature: Feature): string {