(key uint64, value *cacheValue)
| 53 | } |
| 54 | |
| 55 | func (bc *ByteCache) Set(key uint64, value *cacheValue) { |
| 56 | if bc == nil || bc.c == nil || value == nil { |
| 57 | return |
| 58 | } |
| 59 | cost := int64(len(value.msg)) |
| 60 | if cost <= 0 { |
| 61 | cost = 1 |
| 62 | } |
| 63 | // Ristretto's Set is async and may be dropped under contention. |
| 64 | _ = bc.c.Set(key, value, cost) |
| 65 | } |
| 66 | |
| 67 | // Metrics returns Ristretto metrics (may be nil if metrics are disabled). |
| 68 | func (bc *ByteCache) Metrics() *ristretto.Metrics { |