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

Method Set

pkg/compression/service.go:629–639  ·  view source on GitHub ↗

Set 设置缓存

(key string, result *CompressResult)

Source from the content-addressed store, hash-verified

627
628// Set 设置缓存
629func (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 清空缓存
642func (c *CompressionCache) Clear() {

Callers 1

TestCompressionCacheFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestCompressionCacheFunction · 0.76