Skip to content

Commit 04da74e

Browse files
committed
refactor(satellite): update caching logic for tools and resources
1 parent a41d5d0 commit 04da74e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

services/satellite/src/services/stdio-tool-discovery-manager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ export class StdioToolDiscoveryManager {
214214
...(tool._meta ? { _meta: tool._meta } : {})
215215
};
216216

217-
this.toolCache.set(namespacedName, cachedTool);
218-
toolSet.add(namespacedName);
217+
const cacheKey = `${installationName}::${namespacedName}`;
218+
this.toolCache.set(cacheKey, cachedTool);
219+
toolSet.add(cacheKey);
219220
cachedTools.push(cachedTool);
220221
}
221222

@@ -363,7 +364,10 @@ export class StdioToolDiscoveryManager {
363364
* Get a specific tool by namespaced name
364365
*/
365366
getTool(namespacedName: string): CachedStdioTool | null {
366-
return this.toolCache.get(namespacedName) || null;
367+
for (const tool of this.toolCache.values()) {
368+
if (tool.namespacedName === namespacedName) return tool;
369+
}
370+
return null;
367371
}
368372

369373
/**

services/satellite/src/services/unified-resource-discovery-manager.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ export class UnifiedResourceDiscoveryManager {
133133
discoveredAt
134134
};
135135

136-
this.resourceCache.set(namespacedUri, cached);
137-
resourceUriSet.add(namespacedUri);
136+
const cacheKey = `${installationName}::${namespacedUri}`;
137+
this.resourceCache.set(cacheKey, cached);
138+
resourceUriSet.add(cacheKey);
138139
}
139140
this.resourcesByServer.set(installationName, resourceUriSet);
140141

@@ -157,8 +158,9 @@ export class UnifiedResourceDiscoveryManager {
157158
discoveredAt
158159
};
159160

160-
this.templateCache.set(namespacedUri, cached);
161-
templateUriSet.add(namespacedUri);
161+
const cacheKey = `${installationName}::${namespacedUri}`;
162+
this.templateCache.set(cacheKey, cached);
163+
templateUriSet.add(cacheKey);
162164
}
163165
this.templatesByServer.set(installationName, templateUriSet);
164166

@@ -194,7 +196,10 @@ export class UnifiedResourceDiscoveryManager {
194196
* Get resource by namespaced URI
195197
*/
196198
getResource(namespacedUri: string): UnifiedCachedResource | null {
197-
return this.resourceCache.get(namespacedUri) || null;
199+
for (const resource of this.resourceCache.values()) {
200+
if (resource.namespacedUri === namespacedUri) return resource;
201+
}
202+
return null;
198203
}
199204

200205
/**

0 commit comments

Comments
 (0)