Skip to content

Commit 99b26b2

Browse files
author
Colin Wahl
committed
add docs for Cache
1 parent 8c6535b commit 99b26b2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/06-Cache.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# GitHub.Actions.Cache
2+
3+
> Functions necessary for caching dependencies and build outputs to improve workflow execution time.
4+
5+
This module exposes bindings to the [@actions/cache package](https://github.com/actions/toolkit/tree/main/packages/cache). See [the @actions/cache README](https://github.com/actions/toolkit/tree/main/packages/cache#actionscache) for more details and important cache limit information.
6+
7+
## Usage
8+
9+
This package is used by the v2+ versions of our first party cache action. You can find an example implementation in the cache repo [here](https://github.com/actions/cache).
10+
11+
#### Restore Cache
12+
13+
Restores a cache based on `key` and `restoreKeys` to the `paths` provided. Function returns the cache key for cache hit and returns undefined if cache not found.
14+
15+
```purescript
16+
let paths =
17+
[ "node_modules"
18+
, "packages/*/node_modules"
19+
]
20+
let primaryKey = 'npm-foobar-d5ea0750'
21+
let restoreKeys =
22+
[ "npm-foobar-"
23+
, "npm-"
24+
]
25+
Cache.restoreCache { paths, primaryKey, restoreKeys: Just restoreKeys, options: Nothing }
26+
```
27+
28+
#### Save Cache
29+
30+
Saves a cache containing the files in `paths` using the `key` provided. The files would be compressed using zstandard compression algorithm if zstd is installed, otherwise gzip is used. Function returns the cache id if the cache was saved succesfully and throws an error if cache upload fails.
31+
32+
```purescript
33+
let paths =
34+
[ "node_modules"
35+
, "packages/*/node_modules/"
36+
]
37+
let key = 'npm-foobar-d5ea0750'
38+
cacheId <- Cache.saveCache { paths, key }
39+
```
40+

0 commit comments

Comments
 (0)