






















@@ -15,15 +15,18 @@ import {
1515type PackageManifest,
1616} from "./manifest.js";
171718-const INSTALLED_MANIFEST_REGISTRY_CACHE_MAX_ENTRIES = 64;
18+const INSTALLED_MANIFEST_REGISTRY_FALLBACK_CACHE_MAX_ENTRIES = 64;
19192020type InstalledManifestRegistryCacheEntry = {
2121registry: PluginManifestRegistry;
2222lastUsed: number;
2323};
242425-const installedManifestRegistryCache = new Map<string, InstalledManifestRegistryCacheEntry>();
26-let installedManifestRegistryCacheTick = 0;
25+const installedManifestRegistryFallbackCache = new Map<
26+string,
27+InstalledManifestRegistryCacheEntry
28+>();
29+let installedManifestRegistryFallbackCacheTick = 0;
27302831function normalizePluginIdFilter(pluginIds: readonly string[] | undefined): string[] | undefined {
2932if (!pluginIds?.length) {
@@ -131,11 +134,11 @@ function buildInstalledManifestRegistryCacheKey(params: {
131134}
132135133136function getCachedInstalledManifestRegistry(cacheKey: string): PluginManifestRegistry | undefined {
134-const cached = installedManifestRegistryCache.get(cacheKey);
137+const cached = installedManifestRegistryFallbackCache.get(cacheKey);
135138if (!cached) {
136139return undefined;
137140}
138-cached.lastUsed = ++installedManifestRegistryCacheTick;
141+cached.lastUsed = ++installedManifestRegistryFallbackCacheTick;
139142return cached.registry;
140143}
141144@@ -144,29 +147,31 @@ function setCachedInstalledManifestRegistry(
144147registry: PluginManifestRegistry,
145148): void {
146149if (
147-!installedManifestRegistryCache.has(cacheKey) &&
148-installedManifestRegistryCache.size >= INSTALLED_MANIFEST_REGISTRY_CACHE_MAX_ENTRIES
150+!installedManifestRegistryFallbackCache.has(cacheKey) &&
151+installedManifestRegistryFallbackCache.size >=
152+INSTALLED_MANIFEST_REGISTRY_FALLBACK_CACHE_MAX_ENTRIES
149153) {
150154let oldestKey: string | undefined;
151155let oldestTick = Number.POSITIVE_INFINITY;
152-for (const [key, entry] of installedManifestRegistryCache) {
156+for (const [key, entry] of installedManifestRegistryFallbackCache) {
153157if (entry.lastUsed < oldestTick) {
154158oldestKey = key;
155159oldestTick = entry.lastUsed;
156160}
157161}
158162if (oldestKey) {
159-installedManifestRegistryCache.delete(oldestKey);
163+installedManifestRegistryFallbackCache.delete(oldestKey);
160164}
161165}
162-installedManifestRegistryCache.set(cacheKey, {
166+installedManifestRegistryFallbackCache.set(cacheKey, {
163167 registry,
164-lastUsed: ++installedManifestRegistryCacheTick,
168+lastUsed: ++installedManifestRegistryFallbackCacheTick,
165169});
166170}
167171168172export function clearInstalledManifestRegistryCache(): void {
169-installedManifestRegistryCache.clear();
173+installedManifestRegistryFallbackCache.clear();
174+installedManifestRegistryFallbackCacheTick = 0;
170175}
171176172177function resolveInstalledPluginRootDir(record: InstalledPluginIndexRecord): string {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。