From 8d533d0e94c6bbee1edecfe3ce279d542c87780d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 3 Dec 2021 00:12:08 -0500 Subject: [PATCH] Move default hash times to var --- src/utils/getHashCache.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/getHashCache.ts b/src/utils/getHashCache.ts index f843836..14d30c6 100644 --- a/src/utils/getHashCache.ts +++ b/src/utils/getHashCache.ts @@ -4,8 +4,11 @@ import { HashedValue } from "../types/hash.model"; import { Logger } from "../utils/logger"; import { getHash } from "../utils/getHash"; -export async function getHashCache(value: T, times = 5000): Promise { - if (times === 5000) { +const defaultedHashTimes = 5000; +const cachedHashTimes = defaultedHashTimes - 1; + +export async function getHashCache(value: T, times = defaultedHashTimes): Promise { + if (times === defaultedHashTimes) { const hashKey = getHash(value, 1); const result: HashedValue = await getFromRedis(hashKey); return result as T & HashedValue; @@ -25,7 +28,7 @@ async function getFromRedis(key: HashedValue): Promise