Skip to content

Commit

Permalink
Update README.md (#531)
Browse files Browse the repository at this point in the history
more logical to read save cache before restore cache
  • Loading branch information
vikaskedia committed Apr 12, 2021
1 parent b05573d commit 8afb976
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/cache/README.md
Expand Up @@ -10,9 +10,9 @@ 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).

#### Restore Cache
#### Save 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.
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');
Expand All @@ -21,16 +21,12 @@ const paths = [
'packages/*/node_modules/'
]
const key = 'npm-foobar-d5ea0750'
const restoreKeys = [
'npm-foobar-',
'npm-'
]
const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
const cacheId = await cache.saveCache(paths, key)
```

#### Save Cache
#### Restore 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.
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.

```js
const cache = require('@actions/cache');
Expand All @@ -39,6 +35,10 @@ const paths = [
'packages/*/node_modules/'
]
const key = 'npm-foobar-d5ea0750'
const cacheId = await cache.saveCache(paths, key)
const restoreKeys = [
'npm-foobar-',
'npm-'
]
const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
```

0 comments on commit 8afb976

Please sign in to comment.