rename hashKey to be more generic

This commit is contained in:
Michael C
2021-11-27 02:47:18 -05:00
parent 6baa00b76d
commit 5a69de730c
2 changed files with 5 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import redis from "../utils/redis";
import { userHashKey } from "../utils/redisKeys";
import { shaHashKey } from "../utils/redisKeys";
import { HashedValue } from "../types/hash.model";
import { Logger } from "../utils/logger";
import { getHash } from "../utils/getHash";
@@ -14,7 +14,7 @@ export async function getHashCache<T extends string>(value: T, times = 5000): Pr
}
async function getFromRedis<T extends string>(key: HashedValue): Promise<T & HashedValue> {
const redisKey = userHashKey(key);
const redisKey = shaHashKey(key);
const { err, reply } = await redis.getAsync(redisKey);
if (!err && reply) {

View File

@@ -25,8 +25,8 @@ export function ratingHashKey(hashPrefix: VideoIDHash, service: Service): string
return `rating.${service}.${hashPrefix}`;
}
export function userHashKey(userID: HashedValue): string {
if (userID.length !== 64) Logger.warn(`Redis userHash key is not length 64! ${userID}`);
export function shaHashKey(singleIter: HashedValue): string {
if (singleIter.length !== 64) Logger.warn(`Redis sha.hash key is not length 64! ${singleIter}`);
return `user.${userID}`;
return `sha.hash.${singleIter}`;
}