MCPcopy Create free account
hub / github.com/astercloud/aster / NewToolCache

Function NewToolCache

pkg/tools/cache.go:95–114  ·  view source on GitHub ↗

NewToolCache 创建工具缓存

(config *CacheConfig)

Source from the content-addressed store, hash-verified

93
94// NewToolCache 创建工具缓存
95func NewToolCache(config *CacheConfig) *ToolCache {
96 if config == nil {
97 config = DefaultCacheConfig()
98 }
99
100 cache := &ToolCache{
101 config: config,
102 memoryCache: make(map[string]*CacheEntry),
103 stats: &CacheStats{
104 LastCleanupAt: time.Now(),
105 },
106 }
107
108 // 启动后台清理任务
109 if config.Enabled {
110 go cache.cleanupLoop()
111 }
112
113 return cache
114}
115
116// GenerateKey 生成缓存键
117func (c *ToolCache) GenerateKey(toolName string, input map[string]any) string {

Callers 13

mainFunction · 0.92
TestToolCache_ExpirationFunction · 0.85
TestToolCache_FileCacheFunction · 0.85
TestToolCache_DeleteFunction · 0.85
TestToolCache_ClearFunction · 0.85
TestCachedTool_ExecuteFunction · 0.85
TestToolCache_DisabledFunction · 0.85

Calls 2

cleanupLoopMethod · 0.95
DefaultCacheConfigFunction · 0.85

Tested by 12

TestToolCache_ExpirationFunction · 0.68
TestToolCache_FileCacheFunction · 0.68
TestToolCache_DeleteFunction · 0.68
TestToolCache_ClearFunction · 0.68
TestCachedTool_ExecuteFunction · 0.68
TestToolCache_DisabledFunction · 0.68
TestToolCache_CleanupFunction · 0.68