Configurable expiry time

This commit is contained in:
Ajay
2022-08-19 15:40:32 -04:00
parent c3d30b18e2
commit 5a43f46ac0
3 changed files with 5 additions and 4 deletions

View File

@@ -3,8 +3,7 @@ import { Logger } from "../utils/logger";
import { skipSegmentsHashKey, skipSegmentsKey, reputationKey, ratingHashKey, skipSegmentGroupsKey, userFeatureKey } from "./redisKeys";
import { Service, VideoID, VideoIDHash } from "../types/segments.model";
import { Feature, HashedUserID, UserID } from "../types/user.model";
const expiryTime = 2 * 60 * 60;
import { config } from "../config";
async function get<T>(fetchFromDB: () => Promise<T>, key: string): Promise<T> {
try {
@@ -18,7 +17,7 @@ async function get<T>(fetchFromDB: () => Promise<T>, key: string): Promise<T> {
const data = await fetchFromDB();
redis.setEx(key, expiryTime, JSON.stringify(data)).catch((err) => Logger.error(err));
redis.setEx(key, config.redis?.expiryTime, JSON.stringify(data)).catch((err) => Logger.error(err));
return data;
}