* 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)
| 31 | * @returns {{ runId: number | null, groupKey: string }} |
| 32 | */ |
| 33 | function 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 |
no outgoing calls
no test coverage detected