Skip to content

Commit 690b1c9

Browse files
committed
fix: use lru cache replace node cache #141 #136
1 parent c487018 commit 690b1c9

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

apps/server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"got": "11.8.6",
4444
"hbs": "^4.2.0",
4545
"html-minifier": "^4.0.0",
46-
"node-cache": "^5.1.2",
46+
"lru-cache": "^10.2.2",
4747
"prisma": "^5.10.2",
4848
"reflect-metadata": "^0.2.1",
4949
"rxjs": "^7.8.1",

apps/server/src/feeds/feeds.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import { Feed } from 'feed';
1010
import got, { Got } from 'got';
1111
import { load } from 'cheerio';
1212
import { minify } from 'html-minifier';
13-
import NodeCache from 'node-cache';
13+
import { LRUCache } from 'lru-cache';
1414
import pMap from '@cjs-exporter/p-map';
1515

1616
console.log('CRON_EXPRESSION: ', process.env.CRON_EXPRESSION);
1717

18-
const mpCache = new NodeCache({
19-
maxKeys: 1000,
18+
const mpCache = new LRUCache<string, string>({
19+
max: 5000,
2020
});
2121

2222
@Injectable()
@@ -120,7 +120,7 @@ export class FeedsService {
120120
}
121121

122122
async tryGetContent(id: string) {
123-
let content = mpCache.get(id) as string;
123+
let content = mpCache.get(id);
124124
if (content) {
125125
return content;
126126
}

pnpm-lock.yaml

+6-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)