buildcache icon indicating copy to clipboard operation
buildcache copied to clipboard

How do we clean the old cache objects that not useful anymore

Open MartinGaolong opened this issue 3 years ago • 1 comments

Any documents how can we clean the old cache ? I we just delete the file by last modified time, will this affect the performance.

Could you add command to support this?

MartinGaolong avatar May 31 '22 08:05 MartinGaolong

Do you mean cleaning entries older than a certain date/age?

You can of course clean the entire cache with buildcache --clear.

Note that any housekeeping and cleaning can only be done in the local cache. A remote cache works differently: BuildCache has no knowledge about the state and contents of the remote cache, so it has to be configured on the server side to meet your needs (e.g. LRU eviction or age based eviction).

EDIT: It should be safe to manually delete individual files in the local cache, but it is not recommended. First, you might interfere with concurrent cache operations by BuildCache, and second, you may inadvertently delete only a partial cache entry (e.g. one of three files in a cache entry), leaving incomplete / invalid entries in the cache.

The first problem can be avoided if you know that BuildCache isn't running.

The second problem should be handled by BuildCache error handling (i.e. it is designed to be resilient to cache entry corruption), but OTOH it is not something that has been tested extensively.

mbitsnbites avatar Jun 23 '22 09:06 mbitsnbites