From 674b757f16f49d8e30e3d4a4b3fb8c58c33126c1 Mon Sep 17 00:00:00 2001
From: Sergei Zharinov <zharinov@users.noreply.github.com>
Date: Tue, 27 Aug 2024 00:48:21 -0300
Subject: [PATCH] refactor(deno): Use single cache namespace (#31034)

---
 lib/modules/datasource/deno/index.ts | 15 ++++++++-------
 lib/util/cache/package/types.ts      |  2 --
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/modules/datasource/deno/index.ts b/lib/modules/datasource/deno/index.ts
index e396c3b7d8..e9ca1cca05 100644
--- a/lib/modules/datasource/deno/index.ts
+++ b/lib/modules/datasource/deno/index.ts
@@ -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,
@@ -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;
 
@@ -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,
       );
diff --git a/lib/util/cache/package/types.ts b/lib/util/cache/package/types.ts
index b7580902f6..cd0496d867 100644
--- a/lib/util/cache/package/types.ts
+++ b/lib/util/cache/package/types.ts
@@ -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'
-- 
GitLab