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

Method Delete

pkg/tools/cache.go:187–206  ·  view source on GitHub ↗

Delete 删除缓存

(key string)

Source from the content-addressed store, hash-verified

185
186// Delete 删除缓存
187func (c *ToolCache) Delete(key string) error {
188 if !c.config.Enabled {
189 return nil
190 }
191
192 // 从内存删除
193 if c.config.Strategy == CacheStrategyMemory || c.config.Strategy == CacheStrategyBoth {
194 c.deleteFromMemory(key)
195 }
196
197 // 从文件删除
198 if c.config.Strategy == CacheStrategyFile || c.config.Strategy == CacheStrategyBoth {
199 if err := c.deleteFromFile(key); err != nil {
200 c.stats.Errors++
201 return fmt.Errorf("failed to delete file cache: %w", err)
202 }
203 }
204
205 return nil
206}
207
208// Clear 清空所有缓存
209func (c *ToolCache) Clear() error {

Callers 1

TestToolCache_DeleteFunction · 0.95

Calls 2

deleteFromMemoryMethod · 0.95
deleteFromFileMethod · 0.95

Tested by 1

TestToolCache_DeleteFunction · 0.76