mirror of https://github.com/webpack/webpack.git
add direct memory cache
This commit is contained in:
parent
2688b5b17f
commit
4ed5622b53
|
|
@ -102,6 +102,7 @@ class FileCachePlugin {
|
|||
*/
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.directMemoryCache = new Map();
|
||||
}
|
||||
|
||||
static purgeMemoryCache() {
|
||||
|
|
@ -179,6 +180,7 @@ class FileCachePlugin {
|
|||
};
|
||||
const relativeFilename = toHash(identifier) + ".data";
|
||||
const filename = path.join(cacheDirectory, relativeFilename);
|
||||
this.directMemoryCache.set(identifier, entry);
|
||||
memoryCache.set(filename, entry);
|
||||
const promiseFactory =
|
||||
store === "pack"
|
||||
|
|
@ -221,6 +223,16 @@ class FileCachePlugin {
|
|||
compiler.cache.hooks.get.tapPromise(
|
||||
"FileCachePlugin",
|
||||
(identifier, etag) => {
|
||||
const directMemory = this.directMemoryCache.get(identifier);
|
||||
if (directMemory !== undefined) {
|
||||
return Promise.resolve(
|
||||
directMemory.etag !== etag
|
||||
? undefined
|
||||
: typeof directMemory.data === "function"
|
||||
? directMemory.data()
|
||||
: directMemory.data
|
||||
);
|
||||
}
|
||||
const relativeFilename = toHash(identifier) + ".data";
|
||||
const filename = path.join(cacheDirectory, relativeFilename);
|
||||
const logMessage = store === "pack" ? "pack" : filename;
|
||||
|
|
@ -243,6 +255,7 @@ class FileCachePlugin {
|
|||
if (cacheEntry === undefined) return;
|
||||
if (typeof cacheEntry.data === "function")
|
||||
cacheEntry.data = memorize(cacheEntry.data);
|
||||
this.directMemoryCache.set(identifier, cacheEntry);
|
||||
memoryCache.set(filename, cacheEntry);
|
||||
if (cacheEntry === undefined) return;
|
||||
if (cacheEntry.identifier !== identifier) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue