mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-08 12:37:00 +03:00
rename hashKey to be more generic
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import redis from "../utils/redis";
|
import redis from "../utils/redis";
|
||||||
import { userHashKey } from "../utils/redisKeys";
|
import { shaHashKey } from "../utils/redisKeys";
|
||||||
import { HashedValue } from "../types/hash.model";
|
import { HashedValue } from "../types/hash.model";
|
||||||
import { Logger } from "../utils/logger";
|
import { Logger } from "../utils/logger";
|
||||||
import { getHash } from "../utils/getHash";
|
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> {
|
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);
|
const { err, reply } = await redis.getAsync(redisKey);
|
||||||
|
|
||||||
if (!err && reply) {
|
if (!err && reply) {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ export function ratingHashKey(hashPrefix: VideoIDHash, service: Service): string
|
|||||||
return `rating.${service}.${hashPrefix}`;
|
return `rating.${service}.${hashPrefix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function userHashKey(userID: HashedValue): string {
|
export function shaHashKey(singleIter: HashedValue): string {
|
||||||
if (userID.length !== 64) Logger.warn(`Redis userHash key is not length 64! ${userID}`);
|
if (singleIter.length !== 64) Logger.warn(`Redis sha.hash key is not length 64! ${singleIter}`);
|
||||||
|
|
||||||
return `user.${userID}`;
|
return `sha.hash.${singleIter}`;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user