How can I configure Ccache to only use secondary storage as it's cache and completely skip primary storage?
Our CI pipelines use containers to compile and build our C++ application. We want to use Ccache to reduce build times and want the cache to be shared with all pipelines. For this, the secondary storage options of Ccache seem ideal but we don't know how we can configure Ccache to skip the primary storage (local cache) completely.
We would like Ccache to immediately contact the secondary storage but I think it would also be okay if the local cache generated cache misses first. Ideally, the local cache is not updated as to not waste time there. Of course, it's a must-have that the secondary storage is updated whenever a miss occurs.
I was thinking of setting --max-files
or --max-size
to 0
but that is a special value to set no limit at all. Setting those options to 1
would maybe work but it will also needlessly trigger the cleanup logic of Ccache, wasting time.
I also noticed the configuration option read_only
but the documentation clearly states: "... but it will not add new results to any cache backend", which means our secondary storage would never be updated.
You can configure Ccache version 4.7 and newer to use only remote storage (used to be called secondary storage) by setting remote_only = true
in the configuration file, or set the environment variable CCACHE_REMOTE_ONLY
.
Documentation of the feature: https://ccache.dev/manual/4.7.4.html#config_remote_only