MCPcopy Create free account
hub / github.com/github/gh-aw / listMemoryCaches

Function listMemoryCaches

actions/setup/js/cleanup_cache_memory.cjs:64–111  ·  view source on GitHub ↗

* List all caches starting with "memory-" prefix, handling pagination. * Results are sorted newest-first by last_accessed_at from the API. * * @param {any} github - GitHub REST client * @param {string} owner - Repository owner * @param {string} repo - Repository name * @param {number} [listDel

(github, owner, repo, listDelayMs = LIST_DELAY_MS)

Source from the content-addressed store, hash-verified

62 * @returns {Promise<CacheEntry[]>} List of cache entries
63 */
64async function listMemoryCaches(github, owner, repo, listDelayMs = LIST_DELAY_MS) {
65 /** @type {CacheEntry[]} */
66 const caches = [];
67 let page = 1;
68 const perPage = 100;
69
70 while (page <= MAX_LIST_PAGES) {
71 core.info(` Fetching cache list page ${page}...`);
72 const response = await github.rest.actions.getActionsCacheList({
73 owner,
74 repo,
75 key: "memory-",
76 per_page: perPage,
77 page,
78 sort: "last_accessed_at",
79 direction: "desc",
80 });
81
82 const actionsCaches = response.data.actions_caches;
83 if (!actionsCaches || actionsCaches.length === 0) {
84 break;
85 }
86
87 for (const cache of actionsCaches) {
88 if (!cache.key || !cache.key.startsWith("memory-")) {
89 continue;
90 }
91 const { runId, groupKey } = parseCacheKey(cache.key);
92 caches.push({ id: cache.id, key: cache.key, runId, groupKey });
93 }
94
95 core.info(` Page ${page}: ${actionsCaches.length} cache(s) fetched (${caches.length} total)`);
96
97 if (actionsCaches.length < perPage) {
98 break;
99 }
100
101 page++;
102 // Throttle between list pages
103 await delay(listDelayMs);
104 }
105
106 if (page > MAX_LIST_PAGES) {
107 core.warning(`⚠️ Reached maximum page limit (${MAX_LIST_PAGES}). Some caches may not have been listed.`);
108 }
109
110 return caches;
111}
112
113/**
114 * Group caches by their group key (everything except run ID),

Callers 2

mainFunction · 0.85

Calls 2

parseCacheKeyFunction · 0.85
delayFunction · 0.70

Tested by

no test coverage detected