|
21 | 21 | coreSupportsOnPluginInit = false
|
22 | 22 | }
|
23 | 23 |
|
| 24 | +function removeCachedValue(cache, key) { |
| 25 | + if (cache?.del) { |
| 26 | + // if cache expose ".del" method directly on public interface |
| 27 | + return cache.del(key) |
| 28 | + } else if (cache?.cache?.del) { |
| 29 | + // legacy - using internal cache instance and calling ".del" on it directly |
| 30 | + return cache.cache.del(key) |
| 31 | + } |
| 32 | + return Promise.reject( |
| 33 | + new Error(`Cache instance doesn't expose ".del" function`) |
| 34 | + ) |
| 35 | +} |
| 36 | + |
24 | 37 | exports.onCreateDevServer = async ({ app, cache, reporter }) => {
|
25 | 38 | if (!_lazyJobsEnabled()) {
|
26 | 39 | return
|
@@ -53,14 +66,14 @@ exports.onCreateDevServer = async ({ app, cache, reporter }) => {
|
53 | 66 | } = splitOperationsByRequestedFile(cacheResult, pathOnDisk)
|
54 | 67 |
|
55 | 68 | await _unstable_createJob(matchingJob, { reporter })
|
56 |
| - await cache.cache.del(decodedURI) |
| 69 | + await removeCachedValue(cache, decodedURI) |
57 | 70 |
|
58 | 71 | if (jobWithRemainingOperations.args.operations.length > 0) {
|
59 | 72 | // There are still some operations pending for this job - replace the cached job
|
60 |
| - await cache.cache.set(jobContentDigest, jobWithRemainingOperations) |
| 73 | + await cache.set(jobContentDigest, jobWithRemainingOperations) |
61 | 74 | } else {
|
62 | 75 | // No operations left to process - purge the cache
|
63 |
| - await cache.cache.del(jobContentDigest) |
| 76 | + await removeCachedValue(cache, jobContentDigest) |
64 | 77 | }
|
65 | 78 |
|
66 | 79 | return res.sendFile(pathOnDisk)
|
|
0 commit comments