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

Function parseCacheKey

actions/setup/js/cleanup_cache_memory.cjs:33–44  ·  view source on GitHub ↗

* Parse a cache key to extract the run ID and group key in a single pass. * Cache keys follow the pattern: memory-{parts}-{runID} * where runID is the last purely numeric segment. * * @param {string} key - Cache key string * @returns {{ runId: number | null, groupKey: string }}

(key)

Source from the content-addressed store, hash-verified

31 * @returns {{ runId: number | null, groupKey: string }}
32 */
33function parseCacheKey(key) {
34 const parts = key.split("-");
35 for (let i = parts.length - 1; i >= 0; i--) {
36 if (/^\d+$/.test(parts[i])) {
37 return {
38 runId: parseInt(parts[i], 10),
39 groupKey: parts.slice(0, i).join("-"),
40 };
41 }
42 }
43 return { runId: null, groupKey: key };
44}
45
46/**
47 * @typedef {Object} CacheEntry

Callers 2

listMemoryCachesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected