On this page

Abstract cache interface backed by tapable hooks for reading, writing, idle transitions, and shutdown across webpack cache implementations.

new Cache(): Cache
Returns:<Cache>

Initializes the cache lifecycle hooks implemented by cache backends.

  • hooks {{ beginIdle: SyncHook<><<[]>; endIdle: AsyncParallelHook<[]>>; get: AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>; shutdown: AsyncParallelHook<[]>; store: AsyncParallelHook<[string, Etag | null, any]>; storeBuildDependencies: AsyncParallelHook<[Iterable<string, any, any>]> }}
  • STAGE_DEFAULT <number>
  • STAGE_DISK <number>
  • STAGE_MEMORY <number>
  • STAGE_NETWORK <number>
beginIdle(): void
Returns:<void>

Signals that webpack is entering an idle phase and cache backends may flush or compact pending work.


endIdle(callback): void
  • callback {CallbackCacheCache} signals when the call finishes
  • Returns: <void>

Signals that webpack is leaving the idle phase and waits for cache backends to finish any asynchronous resume work.


get(identifier, etag, callback): void
Attributes
identifier:<string>
the cache identifier
etag:<Etag> | <null>
the etag
callback:
{CallbackCacheCache } signals when the value is retrieved
Returns:<void>

Retrieves a cached value and lets registered gotHandlers observe the result before the caller receives it.


shutdown(callback): void
  • callback {CallbackCacheCache} signals when the call finishes
  • Returns: <void>

Shuts down every registered cache backend and waits for cleanup to finish.


store(identifier, etag, data, callback): void
Attributes
identifier:<string>
the cache identifier
etag:<Etag> | <null>
the etag
data:
{T} the value to store
callback:
{CallbackCacheCache } signals when the value is stored
Returns:<void>

Stores a cache entry for the identifier and etag through the registered cache backend hooks.


storeBuildDependencies(dependencies, callback): void
  • dependencies {Iterable} list of all build dependencies
  • callback {CallbackCacheCache} signals when the dependencies are stored
  • Returns: <void>

Persists the set of build dependencies required to determine whether the cache can be restored in a future compilation.

Creates a callback wrapper that waits for a fixed number of completions and forwards the first error immediately.

Attributes
result:
{T}
Returns:<void>

Creates a callback wrapper that waits for a fixed number of completions and forwards the first error immediately.


Creates a callback wrapper that waits for a fixed number of completions and forwards the first error immediately.

Creates a callback wrapper that waits for a fixed number of completions and forwards the first error immediately.