getSetItemBytesOnce duplicate statistics bugs
daoshenzzg opened this issue · 1 comments
daoshenzzg commented
getSetItemBytesOnce duplicate statistics bugs
func (c *jetCache) getSetItemBytesOnce(item *item) (b []byte, cached bool, err error) {
if c.local != nil {
b, ok := c.local.Get(item.key)
if ok {
c.statsHandler.IncrHit()
c.statsHandler.IncrLocalHit()
if bytes.Compare(b, notFoundPlaceholder) == 0 {
return nil, true, c.errNotFound
}
return b, true, nil
}
}
v, err, _ := c.group.Do(item.key, func() (any, error) {
b, err := c.getBytes(item.Context(), item.key, item.skipLocal)
if err == nil {
cached = true
return b, nil
}
}
// ....
}
func (c *jetCache) getBytes(ctx context.Context, key string, skipLocal bool) ([]byte, error) {
if !skipLocal && c.local != nil {
b, ok := c.local.Get(key)
if ok {
c.statsHandler.IncrHit()
c.statsHandler.IncrLocalHit()
if bytes.Compare(b, notFoundPlaceholder) == 0 {
return nil, c.errNotFound
}
return b, nil
}
c.statsHandler.IncrLocalMiss()
}
}
daoshenzzg commented
没有bug。第一次查询,如果未命中,并未统计,第二次未命中才统计。