diff --git a/lib/datasource/cache.ts b/lib/datasource/cache.ts index ecd74cbe79e1764bbf11c59c30366a05dd5bb694..bab0cf1dbf81bb95f6d90e70a0da538ea414fea6 100644 --- a/lib/datasource/cache.ts +++ b/lib/datasource/cache.ts @@ -1,5 +1,5 @@ import { logger } from '../logger'; -import * as globalCache from '../util/cache/global'; +import * as packageCache from '../util/cache/package'; /** * Cache callback result which has to be returned by the `CacheCallback` function. @@ -58,7 +58,10 @@ export async function cacheAble<TArg, TResult = unknown>({ }: CacheConfig<TArg, TResult>): Promise<TResult> { const cacheNamespace = `datasource-${id}`; const cacheKey = JSON.stringify(lookup); - const cachedResult = await globalCache.get<TResult>(cacheNamespace, cacheKey); + const cachedResult = await packageCache.get<TResult>( + cacheNamespace, + cacheKey + ); // istanbul ignore if if (cachedResult) { logger.trace({ id, lookup }, 'datasource cachedResult'); @@ -69,7 +72,7 @@ export async function cacheAble<TArg, TResult = unknown>({ if (isPrivate) { logger.trace({ id, lookup }, 'Skipping datasource cache for private data'); } else { - await globalCache.set(cacheNamespace, cacheKey, data, minutes); + await packageCache.set(cacheNamespace, cacheKey, data, minutes); } return data; } diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts index e6185ed3009a5fe5d21134e58f85abd4d9293acb..9715b4eab1835366fb1494a94b14e5267d0e9995 100644 --- a/lib/datasource/crate/index.ts +++ b/lib/datasource/crate/index.ts @@ -1,6 +1,6 @@ import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { GetReleasesConfig, Release, ReleaseResult } from '../common'; @@ -13,7 +13,7 @@ export async function getReleases({ }: GetReleasesConfig): Promise<ReleaseResult | null> { const cacheNamespace = 'datasource-crate'; const cacheKey = lookupName; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, cacheKey ); @@ -63,7 +63,7 @@ export async function getReleases({ return null; } const cacheMinutes = 10; - await globalCache.set(cacheNamespace, cacheKey, result, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, result, cacheMinutes); return result; } catch (err) { if (err.statusCode === 404 || err.code === 'ENOTFOUND') { diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts index a295738843c9e3b9b08b8f6f0efd5b86dcfff557..4af0da52eac34ecc8fbad39b810ab925e19e3531 100644 --- a/lib/datasource/docker/index.ts +++ b/lib/datasource/docker/index.ts @@ -7,7 +7,7 @@ import wwwAuthenticate from 'www-authenticate'; import { logger } from '../../logger'; import { HostRule } from '../../types'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import * as hostRules from '../../util/host-rules'; import { Http, HttpResponse } from '../../util/http'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -342,7 +342,7 @@ export async function getDigest( const cacheKey = `${registry}:${repository}:${newTag}`; let digest = null; try { - const cachedResult = await globalCache.get(cacheNamespace, cacheKey); + const cachedResult = await packageCache.get(cacheNamespace, cacheKey); // istanbul ignore if if (cachedResult !== undefined) { return cachedResult; @@ -370,7 +370,7 @@ export async function getDigest( ); } const cacheMinutes = 30; - await globalCache.set(cacheNamespace, cacheKey, digest, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, digest, cacheMinutes); return digest; } @@ -382,7 +382,7 @@ async function getTags( try { const cacheNamespace = 'datasource-docker-tags'; const cacheKey = `${registry}:${repository}`; - const cachedResult = await globalCache.get<string[]>( + const cachedResult = await packageCache.get<string[]>( cacheNamespace, cacheKey ); @@ -411,7 +411,7 @@ async function getTags( page += 1; } while (url && page < 20); const cacheMinutes = 15; - await globalCache.set(cacheNamespace, cacheKey, tags, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, tags, cacheMinutes); return tags; } catch (err) /* istanbul ignore next */ { if (err instanceof ExternalHostError) { @@ -482,7 +482,7 @@ async function getLabels( logger.debug(`getLabels(${registry}, ${repository}, ${tag})`); const cacheNamespace = 'datasource-docker-labels'; const cacheKey = `${registry}:${repository}:${tag}`; - const cachedResult = await globalCache.get<Record<string, string>>( + const cachedResult = await packageCache.get<Record<string, string>>( cacheNamespace, cacheKey ); @@ -541,7 +541,7 @@ async function getLabels( ); } const cacheMinutes = 60; - await globalCache.set(cacheNamespace, cacheKey, labels, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, labels, cacheMinutes); return labels; } catch (err) { if (err instanceof ExternalHostError) { diff --git a/lib/datasource/galaxy/index.ts b/lib/datasource/galaxy/index.ts index 14c67e18832feb9a1e76ccab9af0a9c343ce4b4a..ed01e05fe8a44251b1f6572c2844271e8a4b4374 100644 --- a/lib/datasource/galaxy/index.ts +++ b/lib/datasource/galaxy/index.ts @@ -1,6 +1,6 @@ import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { GetReleasesConfig, Release, ReleaseResult } from '../common'; @@ -13,7 +13,7 @@ export async function getReleases({ }: GetReleasesConfig): Promise<ReleaseResult | null> { const cacheNamespace = 'datasource-galaxy'; const cacheKey = lookupName; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, cacheKey ); @@ -90,7 +90,7 @@ export async function getReleases({ } ); const cacheMinutes = 10; - await globalCache.set(cacheNamespace, cacheKey, result, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, result, cacheMinutes); return result; } catch (err) { if ( diff --git a/lib/datasource/git-refs/index.ts b/lib/datasource/git-refs/index.ts index afd75aed8c0bd0418da369e511d8ac04c01a60df..50820ee59209506b5d614d199acfa4c55ae5be99 100644 --- a/lib/datasource/git-refs/index.ts +++ b/lib/datasource/git-refs/index.ts @@ -1,6 +1,6 @@ import simpleGit from 'simple-git/promise'; import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import * as semver from '../../versioning/semver'; import { DigestConfig, GetReleasesConfig, ReleaseResult } from '../common'; @@ -24,7 +24,7 @@ export async function getRawRefs({ try { const cacheNamespace = 'git-raw-refs'; - const cachedResult = await globalCache.get<RawRefs[]>( + const cachedResult = await packageCache.get<RawRefs[]>( cacheNamespace, lookupName ); @@ -68,7 +68,7 @@ export async function getRawRefs({ }) .filter(Boolean) .filter((ref) => ref.type !== 'pull' && !ref.value.endsWith('^{}')); - await globalCache.set(cacheNamespace, lookupName, refs, cacheMinutes); + await packageCache.set(cacheNamespace, lookupName, refs, cacheMinutes); return refs; } catch (err) { logger.info({ err }, `Git-Raw-Refs lookup error in ${lookupName}`); diff --git a/lib/datasource/git-submodules/index.ts b/lib/datasource/git-submodules/index.ts index b00fe9afa52dd4315f2e9c3ebd08b66f0131e462..4a812a3fb748f941b8e850ea981b8ba018773e6b 100644 --- a/lib/datasource/git-submodules/index.ts +++ b/lib/datasource/git-submodules/index.ts @@ -2,7 +2,7 @@ import { URL } from 'url'; import Git from 'simple-git/promise'; import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { DigestConfig, GetReleasesConfig, ReleaseResult } from '../common'; export const id = 'git-submodules'; @@ -13,7 +13,7 @@ export async function getReleases({ }: GetReleasesConfig): Promise<ReleaseResult | null> { const cacheNamespace = 'datasource-git-submodules'; const cacheKey = `${registryUrls[0]}-${registryUrls[1]}`; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, cacheKey ); @@ -42,7 +42,7 @@ export async function getReleases({ ], }; const cacheMinutes = 60; - await globalCache.set(cacheNamespace, cacheKey, result, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, result, cacheMinutes); return result; } catch (err) { logger.debug({ err }, `Git-SubModules lookup error in ${lookupName}`); diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts index 8b4c2c89dcd5030afe0ff40111236a1a0fbbd5eb..438f6509ac5f6aaee85e340c5f0a40cbc00975a8 100644 --- a/lib/datasource/github-releases/index.ts +++ b/lib/datasource/github-releases/index.ts @@ -1,5 +1,5 @@ import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { GithubHttp } from '../../util/http/github'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -28,7 +28,7 @@ export async function getReleases({ lookupName: repo, }: GetReleasesConfig): Promise<ReleaseResult | null> { let githubReleases: GithubRelease[]; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, repo ); @@ -59,6 +59,6 @@ export async function getReleases({ releaseTimestamp: published_at, })); const cacheMinutes = 10; - await globalCache.set(cacheNamespace, repo, dependency, cacheMinutes); + await packageCache.set(cacheNamespace, repo, dependency, cacheMinutes); return dependency; } diff --git a/lib/datasource/github-tags/index.ts b/lib/datasource/github-tags/index.ts index fea2bae705bd85188e8dc9964415af92f17d1677..d2a385a42bafacaee90fa5e954370f8dbe430f03 100644 --- a/lib/datasource/github-tags/index.ts +++ b/lib/datasource/github-tags/index.ts @@ -1,5 +1,5 @@ import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { GithubHttp } from '../../util/http/github'; import { DigestConfig, GetReleasesConfig, ReleaseResult } from '../common'; @@ -24,7 +24,7 @@ async function getTagCommit( githubRepo: string, tag: string ): Promise<string | null> { - const cachedResult = await globalCache.get<string>( + const cachedResult = await packageCache.get<string>( cacheNamespace, getCacheKey(githubRepo, `tag-${tag}`) ); @@ -53,7 +53,7 @@ async function getTagCommit( return null; } const cacheMinutes = 120; - await globalCache.set( + await packageCache.set( cacheNamespace, getCacheKey(githubRepo, `tag-${tag}`), digest, @@ -76,7 +76,7 @@ export async function getDigest( if (newValue && newValue.length) { return getTagCommit(githubRepo, newValue); } - const cachedResult = await globalCache.get( + const cachedResult = await packageCache.get( cacheNamespace, getCacheKey(githubRepo, 'commit') ); @@ -99,7 +99,7 @@ export async function getDigest( return null; } const cacheMinutes = 10; - await globalCache.set( + await packageCache.set( cacheNamespace, getCacheKey(githubRepo, 'commit'), digest, @@ -122,7 +122,7 @@ export async function getReleases({ lookupName: repo, }: GetReleasesConfig): Promise<ReleaseResult | null> { let versions: string[]; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, getCacheKey(repo, 'tags') ); @@ -157,7 +157,7 @@ export async function getReleases({ gitRef: version, })); const cacheMinutes = 10; - await globalCache.set( + await packageCache.set( cacheNamespace, getCacheKey(repo, 'tags'), dependency, diff --git a/lib/datasource/gitlab-tags/index.ts b/lib/datasource/gitlab-tags/index.ts index f9c795ce24ed6ba3c00295c84b3d7bbf4e2aeeeb..59bff4283b83e691e1182fbef5023e515ac79a3d 100644 --- a/lib/datasource/gitlab-tags/index.ts +++ b/lib/datasource/gitlab-tags/index.ts @@ -1,6 +1,6 @@ import URL from 'url'; import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { GitlabHttp } from '../../util/http/gitlab'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -28,7 +28,7 @@ export async function getReleases({ lookupName: repo, }: GetReleasesConfig): Promise<ReleaseResult | null> { let gitlabTags: GitlabTag[]; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, getCacheKey(depHost, repo) ); @@ -72,7 +72,7 @@ export async function getReleases({ })); const cacheMinutes = 10; - await globalCache.set( + await packageCache.set( cacheNamespace, getCacheKey(depHost, repo), dependency, diff --git a/lib/datasource/helm/index.ts b/lib/datasource/helm/index.ts index 24a1910d78937be9c4a44166bfb2ee78d44dc2e7..def7776dbc4f19b424f71421821fc8877743fb4e 100644 --- a/lib/datasource/helm/index.ts +++ b/lib/datasource/helm/index.ts @@ -2,7 +2,7 @@ import yaml from 'js-yaml'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { ensureTrailingSlash } from '../../util/url'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -21,7 +21,7 @@ export async function getRepositoryData( ): Promise<ReleaseResult[]> { const cacheNamespace = 'datasource-helm'; const cacheKey = repository; - const cachedIndex = await globalCache.get(cacheNamespace, cacheKey); + const cachedIndex = await packageCache.get(cacheNamespace, cacheKey); // istanbul ignore if if (cachedIndex) { return cachedIndex; @@ -92,7 +92,7 @@ export async function getRepositoryData( }) ); const cacheMinutes = 20; - await globalCache.set(cacheNamespace, cacheKey, result, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, result, cacheMinutes); return result; } catch (err) { logger.warn(`Failed to parse index.yaml from ${repository}`); diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts index 8c1337fd1b2355b9d7d879c313d559129617ad4b..636a9ea35db7da029de0ed6af0580efffcda4cde 100644 --- a/lib/datasource/maven/index.ts +++ b/lib/datasource/maven/index.ts @@ -3,7 +3,7 @@ import fs from 'fs-extra'; import pAll from 'p-all'; import { XmlDocument } from 'xmldoc'; import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import mavenVersion from '../../versioning/maven'; import { compare } from '../../versioning/maven/compare'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -158,7 +158,7 @@ async function getVersionsFromMetadata( const cacheNamespace = 'datasource-maven-metadata'; const cacheKey = metadataUrl.toString(); - const cachedVersions = await globalCache.get<string[]>( + const cachedVersions = await packageCache.get<string[]>( cacheNamespace, cacheKey ); @@ -173,7 +173,7 @@ async function getVersionsFromMetadata( } const versions = extractVersions(mavenMetadata); - await globalCache.set(cacheNamespace, cacheKey, versions, 10); + await packageCache.set(cacheNamespace, cacheKey, versions, 10); return versions; } @@ -211,7 +211,7 @@ async function filterMissingArtifacts( ): Promise<string[]> { const cacheNamespace = 'datasource-maven-metadata'; const cacheKey = dependency.dependencyUrl; - let artifactsInfo: ArtifactsInfo | null = await globalCache.get< + let artifactsInfo: ArtifactsInfo | null = await packageCache.get< ArtifactsInfo >(cacheNamespace, cacheKey); @@ -243,7 +243,7 @@ async function filterMissingArtifacts( ? 60 : 24 * 60; - await globalCache.set(cacheNamespace, cacheKey, artifactsInfo, cacheTTL); + await packageCache.set(cacheNamespace, cacheKey, artifactsInfo, cacheTTL); } return versions.filter((v) => artifactsInfo[v]); diff --git a/lib/datasource/npm/get.ts b/lib/datasource/npm/get.ts index 2dc1a9047dec7ee2e5fa6fc7e185a52b0530f4a9..932d21f02b455f2c9a247df0996b0a43cc177b2f 100644 --- a/lib/datasource/npm/get.ts +++ b/lib/datasource/npm/get.ts @@ -7,7 +7,7 @@ import registryAuthToken from 'registry-auth-token'; import getRegistryUrl from 'registry-auth-token/registry-url'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { find } from '../../util/host-rules'; import { Http, HttpOptions } from '../../util/http'; import { maskToken } from '../../util/mask'; @@ -71,7 +71,7 @@ export async function getDependency( ); // Now check the persistent cache const cacheNamespace = 'datasource-npm'; - const cachedResult = await globalCache.get<NpmDependency>( + const cachedResult = await packageCache.get<NpmDependency>( cacheNamespace, pkgUrl ); @@ -220,7 +220,7 @@ export async function getDependency( whitelistedPublicScopes.includes(scope) || !packageName.startsWith('@') ) { - await globalCache.set(cacheNamespace, pkgUrl, dep, cacheMinutes); + await packageCache.set(cacheNamespace, pkgUrl, dep, cacheMinutes); } return dep; } catch (err) { diff --git a/lib/datasource/nuget/v3.ts b/lib/datasource/nuget/v3.ts index 507af6cbea354257df51dc48ab932dc5155fd274..58f164e584ca7c556d99c3ebe159a8b10c63d2d9 100644 --- a/lib/datasource/nuget/v3.ts +++ b/lib/datasource/nuget/v3.ts @@ -1,7 +1,7 @@ import * as semver from 'semver'; import { XmlDocument } from 'xmldoc'; import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { ReleaseResult } from '../common'; @@ -21,7 +21,7 @@ export async function getQueryUrl(url: string): Promise<string | null> { // https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource const resourceType = 'SearchQueryService'; const cacheKey = `${url}:${resourceType}`; - const cachedResult = await globalCache.get<string>(cacheNamespace, cacheKey); + const cachedResult = await packageCache.get<string>(cacheNamespace, cacheKey); // istanbul ignore if if (cachedResult) { @@ -38,7 +38,7 @@ export async function getQueryUrl(url: string): Promise<string | null> { const searchQueryServiceId = searchQueryService['@id']; const cacheMinutes = 60; - await globalCache.set( + await packageCache.set( cacheNamespace, cacheKey, searchQueryServiceId, diff --git a/lib/datasource/orb/index.ts b/lib/datasource/orb/index.ts index 0d54db74e9217f98ee6cd6328032fae2c3e64ec2..b26c468dc45dcde9c3676d12a8219b7d234490b2 100644 --- a/lib/datasource/orb/index.ts +++ b/lib/datasource/orb/index.ts @@ -1,5 +1,5 @@ import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -26,7 +26,7 @@ export async function getReleases({ logger.debug({ lookupName }, 'orb.getReleases()'); const cacheNamespace = 'orb'; const cacheKey = lookupName; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, cacheKey ); @@ -66,7 +66,7 @@ export async function getReleases({ })); logger.trace({ dep }, 'dep'); const cacheMinutes = 15; - await globalCache.set(cacheNamespace, cacheKey, dep, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, dep, cacheMinutes); return dep; } catch (err) /* istanbul ignore next */ { logger.debug({ err }, 'CircleCI Orb lookup error'); diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts index e0cdfc57ec694cc67d5ea1f0a84b80db562c3b22..e75d2602f7a66f8c19a06f583bcc23c1cbcf99c3 100644 --- a/lib/datasource/packagist/index.ts +++ b/lib/datasource/packagist/index.ts @@ -3,7 +3,7 @@ import URL from 'url'; import pAll from 'p-all'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import * as runCache from '../../util/cache/run'; import * as hostRules from '../../util/host-rules'; import { Http, HttpOptions } from '../../util/http'; @@ -127,7 +127,7 @@ async function getPackagistFile( const cacheNamespace = 'datasource-packagist-files'; const cacheKey = regUrl + key; // Check the persistent cache for public registries - const cachedResult = await globalCache.get(cacheNamespace, cacheKey); + const cachedResult = await packageCache.get(cacheNamespace, cacheKey); // istanbul ignore if if (cachedResult && cachedResult.sha256 === sha256) { return cachedResult.res; @@ -135,7 +135,7 @@ async function getPackagistFile( const res = (await http.getJson<PackagistFile>(regUrl + '/' + fileName, opts)) .body; const cacheMinutes = 1440; // 1 day - await globalCache.set( + await packageCache.set( cacheNamespace, cacheKey, { res, sha256 }, @@ -233,7 +233,7 @@ function getAllCachedPackages(regUrl: string): Promise<AllPackages | null> { async function packagistOrgLookup(name: string): Promise<ReleaseResult> { const cacheNamespace = 'datasource-packagist-org'; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, name ); @@ -252,7 +252,7 @@ async function packagistOrgLookup(name: string): Promise<ReleaseResult> { logger.trace({ dep }, 'dep'); } const cacheMinutes = 10; - await globalCache.set(cacheNamespace, name, dep, cacheMinutes); + await packageCache.set(cacheNamespace, name, dep, cacheMinutes); return dep; } diff --git a/lib/datasource/pod/index.ts b/lib/datasource/pod/index.ts index 00b6853cabbc285de9937daef46fbdc801d91c09..6832f323ca12dcc1de12bb35011914b2ce249962 100644 --- a/lib/datasource/pod/index.ts +++ b/lib/datasource/pod/index.ts @@ -1,7 +1,7 @@ import crypto from 'crypto'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { GithubHttp } from '../../util/http/github'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -155,7 +155,7 @@ export async function getReleases({ }: GetReleasesConfig): Promise<ReleaseResult | null> { const podName = lookupName.replace(/\/.*$/, ''); - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, registryUrl + podName ); @@ -180,7 +180,7 @@ export async function getReleases({ result = await getReleasesFromCDN(podName, baseUrl); } - await globalCache.set(cacheNamespace, podName, result, cacheMinutes); + await packageCache.set(cacheNamespace, podName, result, cacheMinutes); return result; } diff --git a/lib/datasource/repology/index.ts b/lib/datasource/repology/index.ts index 784b72952e3c07ea234ce95fb0b64693914e2426..c1617de6cad53edb714ce70e9d64cd7e1be154bb 100644 --- a/lib/datasource/repology/index.ts +++ b/lib/datasource/repology/index.ts @@ -1,7 +1,7 @@ import { URLSearchParams } from 'url'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -85,7 +85,7 @@ async function getCachedPackage( ): Promise<RepologyPackage> { // Fetch previous result from cache if available const cacheKey = `${repoName}/${pkgName}`; - const cachedResult = await globalCache.get<RepologyPackage>( + const cachedResult = await packageCache.get<RepologyPackage>( cacheNamespace, cacheKey ); @@ -97,14 +97,14 @@ async function getCachedPackage( // Attempt a binary package lookup and return if successfully const binPkg = await queryPackage(repoName, pkgName, 'binname'); if (binPkg) { - await globalCache.set(cacheNamespace, cacheKey, binPkg, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, binPkg, cacheMinutes); return binPkg; } // Otherwise, attempt a source package lookup and return if successfully const srcPkg = await queryPackage(repoName, pkgName, 'srcname'); if (srcPkg) { - await globalCache.set(cacheNamespace, cacheKey, srcPkg, cacheMinutes); + await packageCache.set(cacheNamespace, cacheKey, srcPkg, cacheMinutes); return srcPkg; } diff --git a/lib/datasource/ruby-version/index.ts b/lib/datasource/ruby-version/index.ts index 433ede5c0612cd34202543e741376fb5e4f1ea51..fa43d545c5e17ec69c355d17ea7c3ddd2c7c7046 100644 --- a/lib/datasource/ruby-version/index.ts +++ b/lib/datasource/ruby-version/index.ts @@ -1,7 +1,7 @@ import { parse } from 'node-html-parser'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { isVersion } from '../../versioning/ruby'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -17,7 +17,7 @@ export async function getReleases( ): Promise<ReleaseResult> { // First check the persistent cache const cacheNamespace = 'datasource-ruby-version'; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, 'all' ); @@ -49,7 +49,7 @@ export async function getReleases( } } } - await globalCache.set(cacheNamespace, 'all', res, 15); + await packageCache.set(cacheNamespace, 'all', res, 15); return res; } catch (err) { throw new ExternalHostError(err); diff --git a/lib/datasource/terraform-module/index.ts b/lib/datasource/terraform-module/index.ts index 5747efb111073067b607c980c8263005848e7e50..217cdcb9827294d71577e1fe40c03d39e4b86834 100644 --- a/lib/datasource/terraform-module/index.ts +++ b/lib/datasource/terraform-module/index.ts @@ -1,6 +1,6 @@ import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -66,7 +66,7 @@ export async function getReleases({ ); const cacheNamespace = 'terraform-module'; const pkgUrl = `${registry}/v1/modules/${repository}`; - const cachedResult = await globalCache.get<ReleaseResult>( + const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, pkgUrl ); @@ -98,7 +98,7 @@ export async function getReleases({ } logger.trace({ dep }, 'dep'); const cacheMinutes = 30; - await globalCache.set(cacheNamespace, pkgUrl, dep, cacheMinutes); + await packageCache.set(cacheNamespace, pkgUrl, dep, cacheMinutes); return dep; } catch (err) { if (err.statusCode === 404 || err.code === 'ENOTFOUND') { diff --git a/lib/manager/bazel/update.ts b/lib/manager/bazel/update.ts index 9d9def06e3e57845ca16200af89c5c96e599247f..8f3110cbec4435e64fe7d159aa94a36e091c3ed0 100644 --- a/lib/manager/bazel/update.ts +++ b/lib/manager/bazel/update.ts @@ -1,6 +1,6 @@ import { fromStream } from 'hasha'; import { logger } from '../../logger'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; import { regEx } from '../../util/regex'; import { UpdateDependencyConfig } from '../common'; @@ -46,7 +46,7 @@ function extractUrls(content: string): string[] | null { async function getHashFromUrl(url: string): Promise<string | null> { const cacheNamespace = 'url-sha256'; - const cachedResult = await globalCache.get<string | null>( + const cachedResult = await packageCache.get<string | null>( cacheNamespace, url ); @@ -59,7 +59,7 @@ async function getHashFromUrl(url: string): Promise<string | null> { algorithm: 'sha256', }); const cacheMinutes = 3 * 24 * 60; // 3 days - await globalCache.set(cacheNamespace, url, hash, cacheMinutes); + await packageCache.set(cacheNamespace, url, hash, cacheMinutes); return hash; } catch (err) /* istanbul ignore next */ { return null; diff --git a/lib/util/cache/global/common.ts b/lib/util/cache/package/common.ts similarity index 84% rename from lib/util/cache/global/common.ts rename to lib/util/cache/package/common.ts index 0742921000bc7ca2cf02df4b9f58253e825e661f..89896e47ac5135e9fedf00e072fad4e4e6f4ef57 100644 --- a/lib/util/cache/global/common.ts +++ b/lib/util/cache/package/common.ts @@ -1,4 +1,4 @@ -export interface GlobalCache { +export interface PackageCache { get<T = any>(namespace: string, key: string): Promise<T>; set<T = any>( diff --git a/lib/util/cache/global/file.spec.ts b/lib/util/cache/package/file.spec.ts similarity index 100% rename from lib/util/cache/global/file.spec.ts rename to lib/util/cache/package/file.spec.ts diff --git a/lib/util/cache/global/file.ts b/lib/util/cache/package/file.ts similarity index 100% rename from lib/util/cache/global/file.ts rename to lib/util/cache/package/file.ts diff --git a/lib/util/cache/global/index.spec.ts b/lib/util/cache/package/index.spec.ts similarity index 100% rename from lib/util/cache/global/index.spec.ts rename to lib/util/cache/package/index.spec.ts diff --git a/lib/util/cache/global/index.ts b/lib/util/cache/package/index.ts similarity index 94% rename from lib/util/cache/global/index.ts rename to lib/util/cache/package/index.ts index 0fb6a2819aa11f4030eada0c508b418e0882546a..d77fdcd8be412ee4fb37ffddc08e01706c62a441 100644 --- a/lib/util/cache/global/index.ts +++ b/lib/util/cache/package/index.ts @@ -1,10 +1,10 @@ import { RenovateConfig } from '../../../config/common'; import * as runCache from '../run'; -import { GlobalCache } from './common'; +import { PackageCache } from './common'; import * as fileCache from './file'; import * as redisCache from './redis'; -let cacheProxy: GlobalCache; +let cacheProxy: PackageCache; function getGlobalKey(namespace: string, key: string): string { return `global%%${namespace}%%${key}`; diff --git a/lib/util/cache/global/redis.ts b/lib/util/cache/package/redis.ts similarity index 100% rename from lib/util/cache/global/redis.ts rename to lib/util/cache/package/redis.ts diff --git a/lib/workers/global/initialize.ts b/lib/workers/global/initialize.ts index 4e36e1f54c45c49d6dc3356beab2497804172d78..f575084b75e4464ad6c7ad7dc955af9106966bc9 100644 --- a/lib/workers/global/initialize.ts +++ b/lib/workers/global/initialize.ts @@ -4,7 +4,7 @@ import fs from 'fs-extra'; import { RenovateConfig } from '../../config/common'; import { logger } from '../../logger'; import { initPlatform } from '../../platform'; -import * as globalCache from '../../util/cache/global'; +import * as packageCache from '../../util/cache/package'; import { setEmojiConfig } from '../../util/emoji'; import * as limits from './limits'; @@ -34,12 +34,12 @@ export async function globalInitialize( let config = config_; config = await initPlatform(config); config = await setDirectories(config); - globalCache.init(config); + packageCache.init(config); limits.init(config); setEmojiConfig(config); return config; } export function globalFinalize(config: RenovateConfig): void { - globalCache.cleanup(config); + packageCache.cleanup(config); } diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index 2ac8bae972b6177270958690f5a1144f89567957..6947671a84132acb20886825db3bdd200f5833ad 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -4,7 +4,7 @@ import { linkify } from 'linkify-markdown'; import MarkdownIt from 'markdown-it'; import { logger } from '../../../logger'; -import * as globalCache from '../../../util/cache/global'; +import * as packageCache from '../../../util/cache/package'; import * as runCache from '../../../util/cache/run'; import { GithubHttp } from '../../../util/http/github'; import { GitlabHttp } from '../../../util/http/gitlab'; @@ -354,7 +354,7 @@ export async function addReleaseNotes( for (const v of input.versions) { let releaseNotes: ChangeLogNotes; const cacheKey = getCacheKey(v.version); - releaseNotes = await globalCache.get(cacheNamespace, cacheKey); + releaseNotes = await packageCache.get(cacheNamespace, cacheKey); if (!releaseNotes) { if (input.project.github != null) { releaseNotes = await getReleaseNotesMd( @@ -385,7 +385,7 @@ export async function addReleaseNotes( releaseNotes = { url: v.compare.url }; } const cacheMinutes = 55; - await globalCache.set( + await packageCache.set( cacheNamespace, cacheKey, releaseNotes, diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts index 33e7a6c0dafc0f23ad60ae6b5d0ca90f7ac43cb9..7965b583aee929e95fe3b99c15deaadcc0f5488a 100644 --- a/lib/workers/pr/changelog/source-github.ts +++ b/lib/workers/pr/changelog/source-github.ts @@ -2,7 +2,7 @@ import URL from 'url'; import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; import { Release } from '../../../datasource'; import { logger } from '../../../logger'; -import * as globalCache from '../../../util/cache/global'; +import * as packageCache from '../../../util/cache/package'; import * as runCache from '../../../util/cache/run'; import * as hostRules from '../../../util/host-rules'; import { GithubHttp } from '../../../util/http/github'; @@ -150,7 +150,7 @@ export async function getChangeLogJSON({ const prev = validReleases[i - 1]; const next = validReleases[i]; if (include(next.version)) { - let release = await globalCache.get( + let release = await packageCache.get( cacheNamespace, getCacheKey(prev.version, next.version) ); @@ -169,7 +169,7 @@ export async function getChangeLogJSON({ release.compare.url = `${baseUrl}${repository}/compare/${prevHead}...${nextHead}`; } const cacheMinutes = 55; - await globalCache.set( + await packageCache.set( cacheNamespace, getCacheKey(prev.version, next.version), release, diff --git a/lib/workers/pr/changelog/source-gitlab.ts b/lib/workers/pr/changelog/source-gitlab.ts index 4826fe4dd612cb695d85f143ea1e8436e8f7d170..72540f21542550b46a9dae8c95e02e84743fade8 100644 --- a/lib/workers/pr/changelog/source-gitlab.ts +++ b/lib/workers/pr/changelog/source-gitlab.ts @@ -1,7 +1,7 @@ import URL from 'url'; import { Release } from '../../../datasource'; import { logger } from '../../../logger'; -import * as globalCache from '../../../util/cache/global'; +import * as packageCache from '../../../util/cache/package'; import * as runCache from '../../../util/cache/run'; import { GitlabHttp } from '../../../util/http/gitlab'; import { regEx } from '../../../util/regex'; @@ -131,7 +131,7 @@ export async function getChangeLogJSON({ const prev = validReleases[i - 1]; const next = validReleases[i]; if (include(next.version)) { - let release = await globalCache.get( + let release = await packageCache.get( cacheNamespace, getCacheKey(prev.version, next.version) ); @@ -149,7 +149,7 @@ export async function getChangeLogJSON({ release.compare.url = `${baseUrl}${repository}/compare/${prevHead}...${nextHead}`; } const cacheMinutes = 55; - await globalCache.set( + await packageCache.set( cacheNamespace, getCacheKey(prev.version, next.version), release,