Delete 删除缓存
(key string)
| 185 | |
| 186 | // Delete 删除缓存 |
| 187 | func (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 清空所有缓存 |
| 209 | func (c *ToolCache) Clear() error { |