11import logger from '@/configs/logger.config' ;
22import { PostRepository } from '@/repositories/post.repository' ;
33import { RawPostType } from '@/types' ;
4- import { cache } from '@/configs/cache.config' ;
4+ // import { cache } from '@/configs/cache.config';
55import { getCurrentKSTDateString , getKSTDateStringWithOffset } from '@/utils/date.util' ;
66
77export class PostService {
88 constructor ( private postRepo : PostRepository ) { }
99
1010 async getAllposts ( userId : number , cursor ?: string , sort : string = '' , isAsc ?: boolean , limit : number = 15 ) {
1111 try {
12- const cacheKey = `posts:user:${ userId } :${ cursor || 'first' } :${ sort } :${ isAsc } :${ limit } ` ;
13- const cachedResult = await cache . get ( cacheKey ) ;
14- if ( cachedResult ) {
15- return cachedResult ;
16- }
12+ // const cacheKey = `posts:user:${userId}:${cursor || 'first'}:${sort}:${isAsc}:${limit}`;
13+ // const cachedResult = await cache.get(cacheKey);
14+ // if (cachedResult) {
15+ // return cachedResult;
16+ // }
1717
1818 let result = null ;
1919 if ( sort === 'viewGrowth' ) {
@@ -39,10 +39,10 @@ export class PostService {
3939 nextCursor : result . nextCursor ,
4040 } ;
4141
42- // 결과가 빈 값이 아니라면 캐시에 저장 (5분 TTL)
43- if ( results . posts . length > 0 ) {
44- await cache . set ( cacheKey , results , 300 ) ;
45- }
42+ // // 결과가 빈 값이 아니라면 캐시에 저장 (5분 TTL)
43+ // if (results.posts.length > 0) {
44+ // await cache.set(cacheKey, results, 300);
45+ // }
4646 return results
4747 } catch ( error ) {
4848 logger . error ( 'PostService getAllposts error : ' , error ) ;
@@ -52,11 +52,11 @@ export class PostService {
5252
5353 async getAllPostsStatistics ( userId : number ) {
5454 try {
55- const cacheKey = `posts:stats:${ userId } ` ;
56- const cachedResult = await cache . get ( cacheKey ) ;
57- if ( cachedResult ) {
58- return cachedResult ;
59- }
55+ // const cacheKey = `posts:stats:${userId}`;
56+ // const cachedResult = await cache.get(cacheKey);
57+ // if (cachedResult) {
58+ // return cachedResult;
59+ // }
6060
6161 const postsStatistics = await this . postRepo . getYesterdayAndTodayViewLikeStats ( userId ) ;
6262
@@ -68,10 +68,10 @@ export class PostService {
6868 lastUpdatedDate : postsStatistics . last_updated_date ,
6969 } ;
7070
71- // 결과가 빈 값이 아니라면 캐시에 저장 (5분 TTL)
72- if ( transformedStatistics . totalViews > 0 ) {
73- await cache . set ( cacheKey , transformedStatistics , 300 ) ;
74- }
71+ // // 결과가 빈 값이 아니라면 캐시에 저장 (5분 TTL)
72+ // if (transformedStatistics.totalViews > 0) {
73+ // await cache.set(cacheKey, transformedStatistics, 300);
74+ // }
7575
7676 return transformedStatistics ;
7777 } catch ( error ) {
0 commit comments