What does restore-keys
do?
#578
-
The README says:
I don't understand what this means. If there is no hit on Looking at the pip example, for example, I don't follow what this part is doing for us: restore-keys: |
${{ runner.os }}-pip- What do we lose if we remove that part from the Action inputs? Can someone illustrate with an example scenario? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @nchammas! The For instance a minimal setup could look like this: - uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} In this example, we're requesting that - uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip- With the addition of I hope that helps! |
Beta Was this translation helpful? Give feedback.
Hey @nchammas!
The
restore-keys
option works as a backup for when the specific cache key you want doesn't return any results.For instance a minimal setup could look like this:
In this example, we're requesting that
~/.cache/pip
is cached using the key provided which could look likeLinux-pip-8156c
. However, the cache will only be restored if the key is a perfect match. This might be exactly what you want it to do, but you might also want it to restore another cache as a backup, which is whererestore-keys
comes into play!