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

Commit bd6483a

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 04c56d2 commit bd6483a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dist/setup/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38975,8 +38975,9 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
3897538975
}
3897638976
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
3897738977
core.debug(`primary key is ${primaryKey}`);
38978+
const restoreKeys = [`node-cache-${platform}-${packageManager}-`];
3897838979
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
38979-
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
38980+
const cacheKey = yield cache.restoreCache([cachePath], primaryKey, restoreKeys);
3898038981
core.setOutput('cache-hit', Boolean(cacheKey));
3898138982
if (!cacheKey) {
3898238983
core.info(`${packageManager} cache is not found`);

src/cache-restore.ts

Lines changed: 2 additions & 1 deletion
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)