Set 设置缓存
(key string, result *CompressResult)
| 627 | |
| 628 | // Set 设置缓存 |
| 629 | func (c *CompressionCache) Set(key string, result *CompressResult) { |
| 630 | c.mu.Lock() |
| 631 | defer c.mu.Unlock() |
| 632 | |
| 633 | // 简单的 LRU:如果超过最大大小,清空缓存 |
| 634 | if len(c.cache) >= c.maxSize { |
| 635 | c.cache = make(map[string]*CompressResult) |
| 636 | } |
| 637 | |
| 638 | c.cache[key] = result |
| 639 | } |
| 640 | |
| 641 | // Clear 清空缓存 |
| 642 | func (c *CompressionCache) Clear() { |
no outgoing calls