File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- let MEMOIZED = { }
3
+ const LRU = require ( 'lru-cache' )
4
+
5
+ const MAX_SIZE = 50 * 1024 * 1024 // 50MB
6
+ const MAX_AGE = 3 * 60 * 1000
7
+
8
+ let MEMOIZED
9
+ clearMemoized ( )
4
10
5
11
module . exports . clearMemoized = clearMemoized
6
12
function clearMemoized ( ) {
7
13
var old = MEMOIZED
8
- MEMOIZED = { }
14
+ MEMOIZED = new LRU ( {
15
+ max : MAX_SIZE ,
16
+ maxAge : MAX_AGE ,
17
+ length : ( entry , key ) => {
18
+ if ( key . startsWith ( 'key:' ) ) {
19
+ return entry . data . length
20
+ } else if ( key . startsWith ( 'digest:' ) ) {
21
+ return entry . length
22
+ }
23
+ }
24
+ } )
9
25
return old
10
26
}
11
27
Original file line number Diff line number Diff line change 52
52
"chownr" : " ^1.0.1" ,
53
53
"glob" : " ^7.1.1" ,
54
54
"graceful-fs" : " ^4.1.10" ,
55
+ "lru-cache" : " ^4.0.2" ,
55
56
"mississippi" : " ^1.2.0" ,
56
57
"mkdirp" : " ^0.5.1" ,
57
58
"promise-inflight" : " ^1.0.1" ,
You can’t perform that action at this time.
0 commit comments