惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
小众软件
小众软件
D
Docker
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
V2EX
博客园 - 叶小钗
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
IT之家
IT之家
博客园 - 司徒正美
M
MIT News - Artificial intelligence
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(plugins): share lookup cache eviction · openclaw...
vincentkoc · 2026-04-27 · via Recent Commits to openclaw:main

@@ -7,6 +7,7 @@ import { buildPluginApi } from "./api-builder.js";

77

import { collectPluginConfigContractMatches } from "./config-contracts.js";

88

import { getCachedPluginJitiLoader, type PluginJitiLoaderCache } from "./jiti-loader-cache.js";

99

import type { PluginManifestRecord } from "./manifest-registry.js";

10+

import { PluginLruCache, type PluginLruCacheResult } from "./plugin-lru-cache.js";

1011

import { loadPluginManifestRegistryForPluginRegistry } from "./plugin-registry.js";

1112

import { resolvePluginCacheInputs } from "./roots.js";

1213

import type { PluginRuntime } from "./runtime/types.js";

@@ -86,20 +87,22 @@ const NOOP_LOGGER: PluginLogger = {

8687

const MAX_SETUP_LOOKUP_CACHE_ENTRIES = 128;

87888889

const jitiLoaders: PluginJitiLoaderCache = new Map();

89-

const setupRegistryCache = new Map<string, PluginSetupRegistry>();

90-

const setupProviderCache = new Map<string, ProviderPlugin | null>();

91-

const setupCliBackendCache = new Map<string, SetupCliBackendEntry | null>();

92-

let setupLookupCacheEntryCap = MAX_SETUP_LOOKUP_CACHE_ENTRIES;

90+

const setupRegistryCache = new PluginLruCache<PluginSetupRegistry>(MAX_SETUP_LOOKUP_CACHE_ENTRIES);

91+

const setupProviderCache = new PluginLruCache<ProviderPlugin | null>(

92+

MAX_SETUP_LOOKUP_CACHE_ENTRIES,

93+

);

94+

const setupCliBackendCache = new PluginLruCache<SetupCliBackendEntry | null>(

95+

MAX_SETUP_LOOKUP_CACHE_ENTRIES,

96+

);

93979498

export const __testing = {

9599

get maxSetupLookupCacheEntries() {

96-

return setupLookupCacheEntryCap;

100+

return setupRegistryCache.maxEntries;

97101

},

98102

setMaxSetupLookupCacheEntriesForTest(value?: number) {

99-

setupLookupCacheEntryCap =

100-

typeof value === "number" && Number.isFinite(value) && value > 0

101-

? Math.max(1, Math.floor(value))

102-

: MAX_SETUP_LOOKUP_CACHE_ENTRIES;

103+

setupRegistryCache.setMaxEntriesForTest(value);

104+

setupProviderCache.setMaxEntriesForTest(value);

105+

setupCliBackendCache.setMaxEntriesForTest(value);

103106

},

104107

getCacheSizes() {

105108

return {

@@ -125,31 +128,12 @@ function getJiti(modulePath: string) {

125128

});

126129

}

127130128-

function getCachedSetupValue<T>(

129-

cache: Map<string, T>,

130-

key: string,

131-

): { hit: true; value: T } | { hit: false } {

132-

if (!cache.has(key)) {

133-

return { hit: false };

134-

}

135-

const cached = cache.get(key) as T;

136-

cache.delete(key);

137-

cache.set(key, cached);

138-

return { hit: true, value: cached };

131+

function getCachedSetupValue<T>(cache: PluginLruCache<T>, key: string): PluginLruCacheResult<T> {

132+

return cache.getResult(key);

139133

}

140134141-

function setCachedSetupValue<T>(cache: Map<string, T>, key: string, value: T): void {

142-

if (cache.has(key)) {

143-

cache.delete(key);

144-

}

135+

function setCachedSetupValue<T>(cache: PluginLruCache<T>, key: string, value: T): void {

145136

cache.set(key, value);

146-

while (cache.size > setupLookupCacheEntryCap) {

147-

const oldestKey = cache.keys().next().value;

148-

if (typeof oldestKey !== "string") {

149-

break;

150-

}

151-

cache.delete(oldestKey);

152-

}

153137

}

154138155139

function buildSetupRegistryCacheKey(params: {