Skip to content

Commit

Permalink
fix: append prefix on restore keys
Browse files Browse the repository at this point in the history
  • Loading branch information
penandlim committed Feb 22, 2024
1 parent 0bbe76e commit 63c4907
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ the `cache` input to `false`, like this:

### Custom Cache Keys

You can also set custom cache keys using the `cache-key` and `cache-restore-keys` inputs. This is useful if you want to
customize how the cache may be shared between jobs. Note that cache-key must be unique for each run to successfully save
without conflicts.
You have the ability to define custom cache keys by utilizing the `cache-key` and `cache-restore-keys` inputs. This
feature is particularly beneficial when you aim to tailor the cache-sharing strategy across multiple jobs. It is
important to ensure that the `cache-key` is unique for each execution to prevent conflicts and guarantee successful
cache saving.

For example, to share the cache across two different jobs, you could do something like this:
For instance, if you wish to utilize a shared cache between two distinct jobs, the following configuration can be
applied:

```yml
- name: Install Foundry
Expand All @@ -86,10 +88,6 @@ For example, to share the cache across two different jobs, you could do somethin
custom-seed-
```

This will create two different caches, one for each job, but they will share the same cache key prefix. This means that
when restoring the cache in the second job, it will look for caches with keys that start with `custom-seed-` as well.
This allows you to share the cache across different jobs, or across different workflows if desired.

#### Deleting Caches

You can delete caches via the GitHub Actions user interface. Just go to your repo's "Actions" page:
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86194,7 +86194,8 @@ async function restoreRPCCache() {
.getInput("cache-restore-keys")
.split(/[\r\n]/)
.map((input) => input.trim())
.filter((input) => input !== "");
.filter((input) => input !== "")
.map((input) => `${prefix}${input}`);
const restoreKeys = customRestoreKeyInput.concat(defaultRestoreKeys);
const cacheKey = await cache.restoreCache(CACHE_PATHS, primaryKey, restoreKeys);
if (!cacheKey) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84687,7 +84687,8 @@ async function restoreRPCCache() {
.getInput("cache-restore-keys")
.split(/[\r\n]/)
.map((input) => input.trim())
.filter((input) => input !== "");
.filter((input) => input !== "")
.map((input) => `${prefix}${input}`);
const restoreKeys = customRestoreKeyInput.concat(defaultRestoreKeys);
const cacheKey = await cache.restoreCache(CACHE_PATHS, primaryKey, restoreKeys);
if (!cacheKey) {
Expand Down
2 changes: 1 addition & 1 deletion dist/save/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ async function restoreRPCCache() {
.getInput("cache-restore-keys")
.split(/[\r\n]/)
.map((input) => input.trim())
.filter((input) => input !== "");
.filter((input) => input !== "")
.map((input) => `${prefix}${input}`);
const restoreKeys = customRestoreKeyInput.concat(defaultRestoreKeys);
const cacheKey = await cache.restoreCache(CACHE_PATHS, primaryKey, restoreKeys);
if (!cacheKey) {
Expand Down

0 comments on commit 63c4907

Please sign in to comment.