1 parent 9106dab commit d39d4e4Copy full SHA for d39d4e4
1 file changed
frontend/src/stores/papers.ts
@@ -1,6 +1,8 @@
1
import { defineStore } from 'pinia';
2
import { fetchPaperPdf } from '@/services/papers';
3
4
+const MAX_PDF_CACHE_SIZE = 40;
5
+
6
export const usePaperStore = defineStore('paper', () => {
7
// module-scoped cache (shared across all store instances)
8
const pdfCache = new Map<number, Blob>();
@@ -15,7 +17,7 @@ export const usePaperStore = defineStore('paper', () => {
15
17
}
16
18
19
// enforce a max cache size using a simple LRU eviction strategy
- if (pdfCache.size >= 40) {
20
+ if (pdfCache.size >= MAX_PDF_CACHE_SIZE) {
21
const oldestKey = pdfCache.keys().next().value as number | undefined;
22
if (oldestKey !== undefined) {
23
pdfCache.delete(oldestKey);
0 commit comments