Skip to content

Commit

Permalink
refactor(deno): Use single cache namespace (#31034)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Aug 27, 2024
1 parent ddcef9c commit 674b757
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 8 additions & 7 deletions lib/modules/datasource/deno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class DenoDatasource extends Datasource {
namespace: `datasource-${DenoDatasource.id}`,
key: ({ packageName, registryUrl }: GetReleasesConfig) =>
// TODO: types (#22198)
`${registryUrl}:${packageName}`,
`getReleases:${registryUrl}:${packageName}`,
})
async getReleases({
packageName,
Expand Down Expand Up @@ -70,14 +70,15 @@ export class DenoDatasource extends Datasource {
}

@cache({
namespace: `datasource-${DenoDatasource.id}-versions`,
key: (moduleAPIURL) => moduleAPIURL,
namespace: `datasource-${DenoDatasource.id}`,
key: (moduleAPIURL) => `getReleaseResult:${moduleAPIURL}`,
})
async getReleaseResult(moduleAPIURL: string): Promise<ReleaseResult> {
const detailsCacheKey = `details:${moduleAPIURL}`;
const releasesCache: Record<string, Release> =
(await packageCache.get(
`datasource-${DenoDatasource.id}-details`,
moduleAPIURL,
`datasource-${DenoDatasource.id}`,
detailsCacheKey,
)) ?? {};
let cacheModified = false;

Expand Down Expand Up @@ -119,8 +120,8 @@ export class DenoDatasource extends Datasource {
if (cacheModified) {
// 1 week. Releases at Deno are immutable, therefore we can use a long term cache here.
await packageCache.set(
`datasource-${DenoDatasource.id}-details`,
moduleAPIURL,
`datasource-${DenoDatasource.id}`,
detailsCacheKey,
releasesCache,
10080,
);
Expand Down
2 changes: 0 additions & 2 deletions lib/util/cache/package/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export type PackageCacheNamespace =
| 'datasource-cpan'
| 'datasource-crate-metadata'
| 'datasource-crate'
| 'datasource-deno-details'
| 'datasource-deno-versions'
| 'datasource-deno'
| 'datasource-docker-architecture'
| 'datasource-docker-hub-cache'
Expand Down

0 comments on commit 674b757

Please sign in to comment.