public async ValueTask <PackageDeprecationMetadataContextInfo?> GetDeprecationMetadataAsync(
            PackageIdentity identity,
            IReadOnlyCollection <PackageSourceContextInfo> packageSources,
            bool includePrerelease,
            CancellationToken cancellationToken)
        {
            Assumes.NotNull(identity);
            Assumes.NotNullOrEmpty(packageSources);

            string cacheId = PackageSearchMetadataCacheItem.GetCacheId(identity.Id, includePrerelease, packageSources);
            PackageSearchMetadataCacheItem?backgroundDataCache = PackageSearchMetadataMemoryCache.Get(cacheId) as PackageSearchMetadataCacheItem;

            if (backgroundDataCache != null)
            {
                PackageSearchMetadataCacheItemEntry cacheItem = await backgroundDataCache.GetPackageSearchMetadataCacheVersionedItemAsync(identity, cancellationToken);

                return(await cacheItem.PackageDeprecationMetadataContextInfo);
            }

            IPackageMetadataProvider packageMetadataProvider = await GetPackageMetadataProviderAsync(packageSources, cancellationToken);

            IPackageSearchMetadata packageMetadata = await packageMetadataProvider.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken);

            PackageDeprecationMetadata deprecationMetadata = await packageMetadata.GetDeprecationMetadataAsync();

            if (deprecationMetadata == null)
            {
                return(null);
            }
            return(PackageDeprecationMetadataContextInfo.Create(deprecationMetadata));
        }
        public async ValueTask <PackageSearchMetadataCacheItemEntry> GetPackageSearchMetadataCacheVersionedItemAsync(PackageIdentity packageIdentity, CancellationToken cancellationToken)
        {
            Assumes.NotNull(packageIdentity);

            if (!_cachedItemEntries.TryGetValue(packageIdentity.Version, out PackageSearchMetadataCacheItemEntry cacheItemEntry))
            {
                IPackageSearchMetadata packageSearchMetadata = await _packageMetadataProvider.GetPackageMetadataAsync(packageIdentity, includePrerelease : true, cancellationToken);

                cacheItemEntry = new PackageSearchMetadataCacheItemEntry(packageSearchMetadata, _packageMetadataProvider);
                _cachedItemEntries[packageIdentity.Version] = cacheItemEntry;
            }

            return(cacheItemEntry);
        }