diff --git a/apps/rush-lib/src/logic/buildCache/AmazonS3BuildCacheProvider.ts b/apps/rush-lib/src/logic/buildCache/AmazonS3BuildCacheProvider.ts index e82813007e..17d7220add 100644 --- a/apps/rush-lib/src/logic/buildCache/AmazonS3BuildCacheProvider.ts +++ b/apps/rush-lib/src/logic/buildCache/AmazonS3BuildCacheProvider.ts @@ -30,6 +30,7 @@ export class AmazonS3BuildCacheProvider extends CloudBuildCacheProviderBase { private readonly _s3Prefix: string | undefined; private readonly _environmentWriteCredential: string | undefined; private readonly _isCacheWriteAllowedByConfiguration: boolean; + private __credentialCacheId: string | undefined; public get isCacheWriteAllowed(): boolean { return this._isCacheWriteAllowedByConfiguration || !!this._environmentWriteCredential; @@ -63,12 +64,17 @@ export class AmazonS3BuildCacheProvider extends CloudBuildCacheProviderBase { } private get _credentialCacheId(): string { - const cacheIdParts: string[] = ['aws-s3', this._s3Region, this._s3Bucket]; + if (!this.__credentialCacheId) { + const cacheIdParts: string[] = ['aws-s3', this._s3Region, this._s3Bucket]; - if (this._isCacheWriteAllowedByConfiguration) { - cacheIdParts.push('cacheWriteAllowed'); + if (this._isCacheWriteAllowedByConfiguration) { + cacheIdParts.push('cacheWriteAllowed'); + } + + this.__credentialCacheId = cacheIdParts.join('|'); } - return cacheIdParts.join('|'); + + return this.__credentialCacheId; } private async _getS3ClientAsync(): Promise { diff --git a/apps/rush-lib/src/logic/buildCache/AzureStorageBuildCacheProvider.ts b/apps/rush-lib/src/logic/buildCache/AzureStorageBuildCacheProvider.ts index 8304a15197..b7e5e52afb 100644 --- a/apps/rush-lib/src/logic/buildCache/AzureStorageBuildCacheProvider.ts +++ b/apps/rush-lib/src/logic/buildCache/AzureStorageBuildCacheProvider.ts @@ -77,7 +77,7 @@ export class AzureStorageBuildCacheProvider extends CloudBuildCacheProviderBase cacheIdParts.push('cacheWriteAllowed'); } - return cacheIdParts.join('|'); + this.__credentialCacheId = cacheIdParts.join('|'); } return this.__credentialCacheId;