Skip to content

Commit 490d99a

Browse files
committed
Refactor LRU cache implementation to use LRUCache with autopurge feature
1 parent 0ed706c commit 490d99a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/app.controller.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Response } from 'express';
44
import { AbstractController } from '~/_common/abstracts/abstract.controller';
55
import { Public } from './_common/decorators/public.decorator';
66
import { ApiBearerAuth, ApiOperation, ApiQuery, ApiResponse } from '@nestjs/swagger';
7-
import LRU from 'lru-cache';
7+
import { LRUCache } from 'lru-cache';
88

99
interface GithubUpdate {
1010
name?: string;
@@ -17,7 +17,10 @@ interface GithubUpdate {
1717
node_id?: string;
1818
}
1919

20-
const storage = new LRU({ ttl: 60 * 60 * 1000 });
20+
const storage = new LRUCache({
21+
ttl: 1000 * 60 * 60,
22+
ttlAutopurge: true,
23+
});
2124

2225
@Public()
2326
@Controller()

0 commit comments

Comments
 (0)