MCPcopy Create free account
hub / github.com/cli/cli / deleteCacheByKey

Function deleteCacheByKey

pkg/cmd/cache/delete/delete.go:218–234  ·  view source on GitHub ↗

deleteCacheByKey deletes cache entries by given key (and optional ref) and returns the number of deleted entries. Note that a key/ref combination does not necessarily map to a single cache entry. There may be more than one entries with the same key/ref combination, but those entries will have diffe

(client *api.Client, repo ghrepo.Interface, key, ref string)

Source from the content-addressed store, hash-verified

216// entry. There may be more than one entries with the same key/ref combination,
217// but those entries will have different IDs.
218func deleteCacheByKey(client *api.Client, repo ghrepo.Interface, key, ref string) (int, error) {
219 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "caches")
220 if err != nil {
221 return 0, err
222 }
223 u.SetQuery("key", key)
224 if ref != "" {
225 u.SetQuery("ref", ref)
226 }
227 var payload shared.CachePayload
228 err = client.REST(repo.RepoHost(), "DELETE", u.String(), nil, &payload)
229 if err != nil {
230 return 0, err
231 }
232
233 return payload.TotalCount, nil
234}
235
236func parseCacheID(arg string) (int64, bool) {
237 id, err := strconv.ParseInt(arg, 10, 64)

Callers 1

deleteCachesFunction · 0.85

Calls 7

JoinPathFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected