@@ -102,6 +102,7 @@ class FileCachePlugin {
102
102
*/
103
103
constructor ( options ) {
104
104
this . options = options ;
105
+ this . directMemoryCache = new Map ( ) ;
105
106
}
106
107
107
108
static purgeMemoryCache ( ) {
@@ -179,6 +180,7 @@ class FileCachePlugin {
179
180
} ;
180
181
const relativeFilename = toHash ( identifier ) + ".data" ;
181
182
const filename = path . join ( cacheDirectory , relativeFilename ) ;
183
+ this . directMemoryCache . set ( identifier , entry ) ;
182
184
memoryCache . set ( filename , entry ) ;
183
185
const promiseFactory =
184
186
store === "pack"
@@ -221,6 +223,16 @@ class FileCachePlugin {
221
223
compiler . cache . hooks . get . tapPromise (
222
224
"FileCachePlugin" ,
223
225
( identifier , etag ) => {
226
+ const directMemory = this . directMemoryCache . get ( identifier ) ;
227
+ if ( directMemory !== undefined ) {
228
+ return Promise . resolve (
229
+ directMemory . etag !== etag
230
+ ? undefined
231
+ : typeof directMemory . data === "function"
232
+ ? directMemory . data ( )
233
+ : directMemory . data
234
+ ) ;
235
+ }
224
236
const relativeFilename = toHash ( identifier ) + ".data" ;
225
237
const filename = path . join ( cacheDirectory , relativeFilename ) ;
226
238
const logMessage = store === "pack" ? "pack" : filename ;
@@ -243,6 +255,7 @@ class FileCachePlugin {
243
255
if ( cacheEntry === undefined ) return ;
244
256
if ( typeof cacheEntry . data === "function" )
245
257
cacheEntry . data = memorize ( cacheEntry . data ) ;
258
+ this . directMemoryCache . set ( identifier , cacheEntry ) ;
246
259
memoryCache . set ( filename , cacheEntry ) ;
247
260
if ( cacheEntry === undefined ) return ;
248
261
if ( cacheEntry . identifier !== identifier ) {
0 commit comments