Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Common/Caching/CasCacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public sealed class CasCacheClient : CacheClient

private readonly ICacheSession? _remoteCacheSession;
private readonly ICacheSession _twoLevelCacheSession;
private readonly bool _remoteCacheIsReadOnly;

public CasCacheClient(
Context rootContext,
Expand Down Expand Up @@ -65,6 +66,7 @@ public CasCacheClient(
else
{
_remoteCacheSession = remoteCache.Value.session;
_remoteCacheIsReadOnly = remoteCache.Value.config.RemoteCacheIsReadOnly;
cacheSession = new TwoLevelCacheSession(
nameof(TwoLevelCacheSession),
localCacheSession,
Expand Down Expand Up @@ -202,7 +204,11 @@ static async Task checkUploadResultsAsync(List<Task<PutFileOperation>> uploadTas
}

// Now that we've ensured everything is in the local cache, we can upload to the remote cache.
if (_remoteCacheSession != null)
// When the remote cache is read-only, skip this entirely: the content hash list which would reference
// this content is not published either (TwoLevelCacheSession honors RemoteCacheIsReadOnly below), so any
// content uploaded here could never be retrieved by a subsequent build. Uploading it would only cost
// egress, storage and time.
if (_remoteCacheSession != null && !_remoteCacheIsReadOnly)
{
// determine what needs to be uploaded
PutFileOperation[] pinResults = await PinBulkAsync(context, _remoteCacheSession, _putRemoteTaskCache, pinContentHashes, cancellationToken);
Expand Down