Allow video labels cashing with prefix of 4

This commit is contained in:
Ajay
2025-01-18 00:22:17 -05:00
parent 2455d2cd7e
commit 80b1019783
2 changed files with 3 additions and 4 deletions

View File

@@ -81,7 +81,7 @@ async function getSegmentsFromDBByHash(hashedVideoIDPrefix: VideoIDHash, service
[`${hashedVideoIDPrefix}%`, service] [`${hashedVideoIDPrefix}%`, service]
) as Promise<DBSegment[]>; ) as Promise<DBSegment[]>;
if (hashedVideoIDPrefix.length === 3) { if (hashedVideoIDPrefix.length === 3 || hashedVideoIDPrefix.length === 4) {
return await QueryCacher.get(fetchFromDB, videoLabelsHashKey(hashedVideoIDPrefix, service)); return await QueryCacher.get(fetchFromDB, videoLabelsHashKey(hashedVideoIDPrefix, service));
} }

View File

@@ -58,10 +58,9 @@ export const videoLabelsKey = (videoID: VideoID, service: Service): string =>
`labels.v2.${service}.videoID.${videoID}`; `labels.v2.${service}.videoID.${videoID}`;
export function videoLabelsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string { export function videoLabelsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string {
hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 3) as VideoIDHash; const length = hashedVideoIDPrefix.length;
if (hashedVideoIDPrefix.length !== 3) Logger.warn(`Redis video labels hash-prefix key is not length 3! ${hashedVideoIDPrefix}`);
return `labels.v1.${service}.${hashedVideoIDPrefix}`; return `labels.v1.${length}.${service}.${hashedVideoIDPrefix}`;
} }
export function userFeatureKey (userID: HashedUserID, feature: Feature): string { export function userFeatureKey (userID: HashedUserID, feature: Feature): string {