MCPcopy Create free account
hub / github.com/echoVic/blade-code / set

Method set

src/context/storage/CacheStore.ts:28–44  ·  view source on GitHub ↗

* 设置缓存项

(key: string, data: T, ttl?: number)

Source from the content-addressed store, hash-verified

26 * 设置缓存项
27 */
28 set<T>(key: string, data: T, ttl?: number): void {
29 const now = Date.now();
30 const item: CacheItem<T> = {
31 data,
32 timestamp: now,
33 accessCount: 0,
34 lastAccess: now,
35 ttl: ttl || this.defaultTTL,
36 };
37
38 // 如果缓存已满,删除最不常用的项
39 if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
40 this.evictLeastUsed();
41 }
42
43 this.cache.set(key, item);
44 }
45
46 /**
47 * 获取缓存项

Callers 15

cacheMessageSummaryMethod · 0.95
cacheToolResultMethod · 0.95
warmupMethod · 0.95
registerToolMethod · 0.80
callToolMethod · 0.80
executeFunction · 0.80
analyzeCodeStructureFunction · 0.80
loadBuiltInRolesMethod · 0.80
addRoleMethod · 0.80
importRolesMethod · 0.80

Calls 2

evictLeastUsedMethod · 0.95
hasMethod · 0.80

Tested by

no test coverage detected