-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap incremental cache in an IPC server (#53030)
This uses an IPC server (if available) for incremental cache methods to help prevent race conditions when reading/writing from cache and also to dedupe requests in cases where multiple cache reads are in flight. This cuts down on data fetching across the different build-time workers. Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
- Loading branch information
Showing
16 changed files
with
455 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { createIpcServer } from './server-ipc' | ||
import { IncrementalCache } from './incremental-cache' | ||
|
||
let initializeResult: | ||
| undefined | ||
| { | ||
ipcPort: number | ||
ipcValidationKey: string | ||
} | ||
|
||
export async function initialize( | ||
...constructorArgs: ConstructorParameters<typeof IncrementalCache> | ||
): Promise<NonNullable<typeof initializeResult>> { | ||
const incrementalCache = new IncrementalCache(...constructorArgs) | ||
|
||
const { ipcPort, ipcValidationKey } = await createIpcServer({ | ||
async revalidateTag( | ||
...args: Parameters<IncrementalCache['revalidateTag']> | ||
) { | ||
return incrementalCache.revalidateTag(...args) | ||
}, | ||
|
||
async get(...args: Parameters<IncrementalCache['get']>) { | ||
return incrementalCache.get(...args) | ||
}, | ||
|
||
async set(...args: Parameters<IncrementalCache['set']>) { | ||
return incrementalCache.set(...args) | ||
}, | ||
|
||
async lock(...args: Parameters<IncrementalCache['lock']>) { | ||
return incrementalCache.lock(...args) | ||
}, | ||
|
||
async unlock(...args: Parameters<IncrementalCache['unlock']>) { | ||
return incrementalCache.unlock(...args) | ||
}, | ||
} as any) | ||
|
||
return { | ||
ipcPort, | ||
ipcValidationKey, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
22ca859
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS. Breaking cache #56355 (comment)