The documentation explains how it is possible to restore cache from partial key matching, which can help obtaining an older version of the cache, not perfectly fitted but better than downloading everything.
And, for an organization, there is a unique setting controlling the cache lifetime (set in days)
My question is: are all caches invalidated at once, or does it happen per cache, based on their individual ages?
The answer will help me find the best approach to cache management in the following case:
Consider a project with the following restore config
restore_cache:
keys:
- v1-myapp-{{ arch }}-{{ checksum "project.clj" }}
- v1-myapp-{{ arch }}-
- v1-myapp-
And consider the following timeline, with a 7-day cache lifetime
- Day 1: create
v1-myapp-linux-abc
- Day 3: create
v1-myapp-macos-cde
- Day 5: create
v1-myapp-linux-xyz
On day 8, cache v1-myapp-linux-abc
becomes invalid and must be rebuild. If v1-myapp-macos-cde
or v1-myapp-linux-xyz
still exist, we will rebuild the cache from them and add some missing deps, growing the cache.
Then, on day 10, v1-myapp-macos-cde
becomes invalid and is rebuilt from either v1-myapp-linux-xyz
or v1-myapp-linux-abc
, with even more deps
There would be a snowball effect where caches keep growing.
Because our system has hundreds of concurrent builds, it is hard for me to track down the right job that create the cache after invalidation (and even figure which one sees first an invalid cache), hence my general question here.
I don’t mind if the answer is that this snowball effect is a thing. It would simply be another thing to consider when creating caches.
But not knowing is the worst
Cheers