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

Commit

Permalink
provide fallback cache keys
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nigelzor committed Dec 8, 2021
1 parent 04c56d2 commit bd6483a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38975,8 +38975,9 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
}
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`);
const restoreKeys = [`node-cache-${platform}-${packageManager}-`];
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
const cacheKey = yield cache.restoreCache([cachePath], primaryKey, restoreKeys);
core.setOutput('cache-hit', Boolean(cacheKey));
if (!cacheKey) {
core.info(`${packageManager} cache is not found`);
Expand Down
3 changes: 2 additions & 1 deletion src/cache-restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export const restoreCache = async (

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

core.saveState(State.CachePrimaryKey, primaryKey);

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

if (!cacheKey) {
Expand Down

0 comments on commit bd6483a

Please sign in to comment.