mirror of https://github.com/actions/toolkit
parent
b05573d945
commit
8afb976445
|
@ -10,6 +10,20 @@ Note that GitHub will remove any cache entries that have not been accessed in ov
|
||||||
|
|
||||||
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).
|
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).
|
||||||
|
|
||||||
|
#### Save Cache
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const cache = require('@actions/cache');
|
||||||
|
const paths = [
|
||||||
|
'node_modules',
|
||||||
|
'packages/*/node_modules/'
|
||||||
|
]
|
||||||
|
const key = 'npm-foobar-d5ea0750'
|
||||||
|
const cacheId = await cache.saveCache(paths, key)
|
||||||
|
```
|
||||||
|
|
||||||
#### Restore Cache
|
#### Restore Cache
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
@ -28,17 +42,3 @@ const restoreKeys = [
|
||||||
const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
|
const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Save Cache
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const cache = require('@actions/cache');
|
|
||||||
const paths = [
|
|
||||||
'node_modules',
|
|
||||||
'packages/*/node_modules/'
|
|
||||||
]
|
|
||||||
const key = 'npm-foobar-d5ea0750'
|
|
||||||
const cacheId = await cache.saveCache(paths, key)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue