matus-chochlik / ctcache

Cache for clang-tidy static analysis results
Boost Software License 1.0
84 stars 30 forks source link

Order of local versus remote caches when doing lookups and stores #51

Closed bartdesmet closed 7 months ago

bartdesmet commented 7 months ago

I was perusing the code a little more in the context of https://github.com/matus-chochlik/ctcache/issues/50, and stumbled upon the logic that adds the caches:

https://github.com/matus-chochlik/ctcache/blob/main/clang-tidy-cache#L896

        if not self._caches or opts.cache_locally():
            self._caches.append(ClangTidyLocalCache(log, opts))

I'd expect the local cache to be prepended to the list, rather than appended, such that methods like is_cached and get_cache_data would check the local cache first, and hence avoid making more expensive remote calls.

Am I missing something obvious here? If not, would it make sense to tweak this?

matus-chochlik commented 7 months ago

I've made some small changes to add the local cache as the first one if it is enabled in the options or to use it as the fallback if there are none others.

bartdesmet commented 7 months ago

Thanks for the quick response!