/// <inheritdoc />
        public async Task <ObjectResult <ContentHashListWithCacheMetadata> > AddContentHashListAsync(
            Context context,
            string cacheNamespace,
            StrongFingerprint strongFingerprint,
            ContentHashListWithCacheMetadata valueToAdd,
            bool forceUpdate)
        {
            try
            {
                ContentHashListResponse addResult = await ArtifactHttpClientErrorDetectionStrategy.ExecuteWithTimeoutAsync(
                    context,
                    "AddContentHashList",
                    innerCts => _buildCacheHttpClient.AddContentHashListAsync(
                        cacheNamespace,
                        strongFingerprint,
                        valueToAdd,
                        forceUpdate), CancellationToken.None).ConfigureAwait(false);

                // The return value is null if the server fails adding content hash list to the backing store.
                // See BuildCacheService.AddContentHashListAsync for more details about the implementation invariants/guarantees.
                if (addResult != null)
                {
                    DownloadUriCache.Instance.BulkAddDownloadUris(addResult.BlobDownloadUris);
                }

                // add succeeded but returned an empty contenthashlistwith cache metadata. correct this.
                if (addResult?.ContentHashListWithCacheMetadata == null)
                {
                    return
                        (new ObjectResult <ContentHashListWithCacheMetadata>(
                             new ContentHashListWithCacheMetadata(
                                 new ContentHashListWithDeterminism(null, valueToAdd.ContentHashListWithDeterminism.Determinism),
                                 valueToAdd.GetRawExpirationTimeUtc(),
                                 valueToAdd.ContentGuarantee,
                                 valueToAdd.HashOfExistingContentHashList)));
                }
                else if (addResult.ContentHashListWithCacheMetadata.ContentHashListWithDeterminism.ContentHashList != null &&
                         addResult.ContentHashListWithCacheMetadata.HashOfExistingContentHashList == null)
                {
                    return(new ObjectResult <ContentHashListWithCacheMetadata>(
                               new ContentHashListWithCacheMetadata(
                                   addResult.ContentHashListWithCacheMetadata.ContentHashListWithDeterminism,
                                   addResult.ContentHashListWithCacheMetadata.GetRawExpirationTimeUtc(),
                                   addResult.ContentHashListWithCacheMetadata.ContentGuarantee,
                                   addResult.ContentHashListWithCacheMetadata.ContentHashListWithDeterminism.ContentHashList.GetHashOfHashes())));
                }
                else
                {
                    return(new ObjectResult <ContentHashListWithCacheMetadata>(addResult.ContentHashListWithCacheMetadata));
                }
            }
            catch (Exception ex)
            {
                return(new ObjectResult <ContentHashListWithCacheMetadata>(ex));
            }
        }
        /// <inheritdoc />
        public async Task <ObjectResult <ContentHashListWithCacheMetadata> > AddContentHashListAsync(
            Context context,
            string cacheNamespace,
            StrongFingerprint strongFingerprint,
            ContentHashListWithCacheMetadata valueToAdd)
        {
            try
            {
                ContentHashListResponse addResult = await ArtifactHttpClientErrorDetectionStrategy.ExecuteWithTimeoutAsync(
                    context,
                    "AddContentHashList",
                    innerCts => _buildCacheHttpClient.AddContentHashListAsync(
                        cacheNamespace,
                        strongFingerprint,
                        valueToAdd), CancellationToken.None).ConfigureAwait(false);

                DownloadUriCache.Instance.BulkAddDownloadUris(addResult.BlobDownloadUris);

                // add succeeded but returned an empty contenthashlistwith cache metadata. correct this.
                if (addResult.ContentHashListWithCacheMetadata == null)
                {
                    return
                        (new ObjectResult <ContentHashListWithCacheMetadata>(
                             new ContentHashListWithCacheMetadata(
                                 new ContentHashListWithDeterminism(null, valueToAdd.ContentHashListWithDeterminism.Determinism),
                                 valueToAdd.GetEffectiveExpirationTimeUtc(),
                                 valueToAdd.ContentGuarantee,
                                 valueToAdd.HashOfExistingContentHashList)));
                }
                else if (addResult.ContentHashListWithCacheMetadata.ContentHashListWithDeterminism.ContentHashList != null &&
                         addResult.ContentHashListWithCacheMetadata.HashOfExistingContentHashList == null)
                {
                    return(new ObjectResult <ContentHashListWithCacheMetadata>(
                               new ContentHashListWithCacheMetadata(
                                   addResult.ContentHashListWithCacheMetadata.ContentHashListWithDeterminism,
                                   addResult.ContentHashListWithCacheMetadata.GetEffectiveExpirationTimeUtc(),
                                   addResult.ContentHashListWithCacheMetadata.ContentGuarantee,
                                   addResult.ContentHashListWithCacheMetadata.ContentHashListWithDeterminism.ContentHashList.GetHashOfHashes())));
                }
                else
                {
                    return(new ObjectResult <ContentHashListWithCacheMetadata>(addResult.ContentHashListWithCacheMetadata));
                }
            }
            catch (Exception ex)
            {
                return(new ObjectResult <ContentHashListWithCacheMetadata>(ex));
            }
        }