move all db and cache logic from service to repositories

This commit is contained in:
rafiarrafif
2025-05-25 21:37:55 +07:00
parent 03fd0531af
commit ee8e8d08db
6 changed files with 76 additions and 11 deletions

View File

@ -0,0 +1,15 @@
import { AppError } from "../../../helpers/error/instances/app";
import { checkUserSessionInCacheRepo } from "../repositories/checkUserSessionInCache.repository";
export const checkUserSessionInCacheService = async (
userId: string,
sessionId: string
) => {
const redisKeyName = `${process.env.app_name}:users:${userId}:sessions:${sessionId}`;
try {
const userSessionInRedis = await checkUserSessionInCacheRepo(redisKeyName);
return userSessionInRedis;
} catch {
throw new AppError(502, "Server cache error");
}
};