Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 455d267

Browse files
authored
Merge pull request actions#804 from actions/Phantsure-patch-1
Update README to call out for version of cache
2 parents 95f200e + 11dd805 commit 455d267

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,58 @@ steps:
177177

178178
> Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`)
179179

180+
181+
## Cache Version
182+
Cache version is unique for a combination of compression tool used for compression of cache (Gzip, Zstd, etc based on runner OS) and the path of directories being cached. If two caches have different versions, they are identified as unique cache entries. This also means that a cache created on `windows-latest` runner can't be restored on `ubuntu-latest` as cache `Version`s are different.
183+
184+
Example: Below example will create 3 unique caches with same keys. Ubuntu and windows runners will use different compression technique and hence create two different caches. And `build-linux` will create two different caches as the `paths` are different.
185+
186+
```yaml
187+
jobs:
188+
build-linux:
189+
runs-on: ubuntu-latest
190+
steps:
191+
- uses: actions/checkout@v3
192+
193+
- name: Cache Primes
194+
id: cache-primes
195+
uses: actions/cache@v3
196+
with:
197+
path: prime-numbers
198+
key: primes
199+
200+
- name: Generate Prime Numbers
201+
if: steps.cache-primes.outputs.cache-hit != 'true'
202+
run: ./generate-primes.sh -d prime-numbers
203+
204+
- name: Cache Numbers
205+
id: cache-numbers
206+
uses: actions/cache@v3
207+
with:
208+
path: numbers
209+
key: primes
210+
211+
- name: Generate Numbers
212+
if: steps.cache-numbers.outputs.cache-hit != 'true'
213+
run: ./generate-primes.sh -d numbers
214+
215+
build-windows:
216+
runs-on: windows-latest
217+
steps:
218+
- uses: actions/checkout@v3
219+
220+
- name: Cache Primes
221+
id: cache-primes
222+
uses: actions/cache@v3
223+
with:
224+
path: prime-numbers
225+
key: primes
226+
227+
- name: Generate Prime Numbers
228+
if: steps.cache-primes.outputs.cache-hit != 'true'
229+
run: ./generate-primes -d prime-numbers
230+
```
231+
180232
## Contributing
181233
We would love for you to contribute to `actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
182234

0 commit comments

Comments
 (0)