Skip to content

Commit

Permalink
fix: use lru cache replace node cache cooderl#141 cooderl#136
Browse files Browse the repository at this point in the history
  • Loading branch information
cooderl committed May 20, 2024
1 parent c487018 commit 690b1c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"got": "11.8.6",
"hbs": "^4.2.0",
"html-minifier": "^4.0.0",
"node-cache": "^5.1.2",
"lru-cache": "^10.2.2",
"prisma": "^5.10.2",
"reflect-metadata": "^0.2.1",
"rxjs": "^7.8.1",
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/feeds/feeds.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { Feed } from 'feed';
import got, { Got } from 'got';
import { load } from 'cheerio';
import { minify } from 'html-minifier';
import NodeCache from 'node-cache';
import { LRUCache } from 'lru-cache';
import pMap from '@cjs-exporter/p-map';

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

const mpCache = new NodeCache({
maxKeys: 1000,
const mpCache = new LRUCache<string, string>({
max: 5000,
});

@Injectable()
Expand Down Expand Up @@ -120,7 +120,7 @@ export class FeedsService {
}

async tryGetContent(id: string) {
let content = mpCache.get(id) as string;
let content = mpCache.get(id);
if (content) {
return content;
}
Expand Down
24 changes: 6 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 690b1c9

Please sign in to comment.