This commit is contained in:
xing 2023-11-07 15:36:00 +08:00
parent 928a608878
commit f6a5cf4255

12
cache/map.go vendored
View File

@ -151,22 +151,18 @@ func (m *MapCache[K, V]) getBatchToMap(e Expend[K, V]) func(c context.Context, k
var needIndex = make(map[K]int)
var err error
mm, err := e.Gets(ctx, key)
if err != nil {
return nil, err
if err != nil || len(key) == len(mm) {
return mm, err
}
res = mm
var flushKeys []K
for i, k := range key {
v, ok := mm[k]
_, ok := mm[k]
if !ok {
flushKeys = append(flushKeys, k)
needIndex[k] = i
} else {
res[k] = v
}
}
if len(needIndex) < 1 {
return res, nil
}
call := func() {
m.mux.Lock()