Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit 3ec743e

Browse files
committed
provide fallback cache keys
it's a lot faster to start from a 90% correct cache than an empty one re: actions#286 re: actions#323 re: actions#328
1 parent 64ed1c7 commit 3ec743e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dist/setup/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -73046,8 +73046,9 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
7304673046
}
7304773047
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
7304873048
core.debug(`primary key is ${primaryKey}`);
73049+
const restoreKeys = [`node-cache-${platform}-${packageManager}-`];
7304973050
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
73050-
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
73051+
const cacheKey = yield cache.restoreCache([cachePath], primaryKey, restoreKeys);
7305173052
core.setOutput('cache-hit', Boolean(cacheKey));
7305273053
if (!cacheKey) {
7305373054
core.info(`${packageManager} cache is not found`);

src/cache-restore.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ export const restoreCache = async (
3838

3939
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
4040
core.debug(`primary key is ${primaryKey}`);
41+
const restoreKeys = [`node-cache-${platform}-${packageManager}-`];
4142

4243
core.saveState(State.CachePrimaryKey, primaryKey);
4344

44-
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
45+
const cacheKey = await cache.restoreCache([cachePath], primaryKey, restoreKeys);
4546
core.setOutput('cache-hit', Boolean(cacheKey));
4647

4748
if (!cacheKey) {

0 commit comments

Comments
 (0)