MCPcopy
hub / github.com/golang/groupcache / add

Method add

groupcache.go:420–434  ·  view source on GitHub ↗
(key string, value ByteView)

Source from the content-addressed store, hash-verified

418}
419
420func (c *cache) add(key string, value ByteView) {
421 c.mu.Lock()
422 defer c.mu.Unlock()
423 if c.lru == nil {
424 c.lru = &lru.Cache{
425 OnEvicted: func(key lru.Key, value interface{}) {
426 val := value.(ByteView)
427 c.nbytes -= int64(len(key.(string))) + int64(val.Len())
428 c.nevict++
429 },
430 }
431 }
432 c.lru.Add(key, value)
433 c.nbytes += int64(len(key)) + int64(value.Len())
434}
435
436func (c *cache) get(key string) (value ByteView, ok bool) {
437 c.mu.Lock()

Callers 1

populateCacheMethod · 0.80

Calls 2

LenMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected