This is a followup/alternative to another idea I just submitted (CCI-I-1467, not visible yet). If CCI-I-1467 is implemented then I think it would mostly remove the need for this idea, but this is proposed as an alternative implementation.I would like to have a way to check for the existence of a cache entry by a specific key. Ideally this would be a function available in scripting, or at least offer a way to execute different code paths depending on whether the cache entry exists or not.The use case I find myself having: there are several initialization jobs that prepare caches for jobs later in the workflow. Many times this cache already exists if dependencies have not changed across builds. In those cases, I can skip the entire job rather than going through these steps:Run restore_cacheRun a dependency tool (bundle, yarn, etc.)Run save_cache to save the updated dependencies to the cache99% of the time, none of the dependencies have changed, but the job still needs to run through the steps above. I realize that steps 2 and 3 could be skipped if I checked for the presence of the cached files after restore. However, this would prevent the use of partial caches, meaning the improved flow would be:Run restore_cache for a specific cache keyCheck for the presence of cached files, and exit 0 if it existsRun restore_cache with partial key(s)Run jobSave cacheThis would improve the performance slightly for builds where the specific cache key already exists, but there's still the overhead of restoring the cached version (that isn't even used), and also the overhead of spinning up the environment.Example usageif cache_key_exists "source-v1-{{ .Branch }}-{{ .Revision }}"; then circleci-agent step halt; fi
CCI-I-1468