(key string, value ByteView)
| 418 | } |
| 419 | |
| 420 | func (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 | |
| 436 | func (c *cache) get(key string) (value ByteView, ok bool) { |
| 437 | c.mu.Lock() |
no test coverage detected