optimize optimize......

This commit is contained in:
xing 2023-10-28 18:37:00 +08:00
parent 71ddf299e4
commit cd4787991d

14
cache/map.go vendored
View File

@ -164,17 +164,15 @@ func (m *MapCache[K, V]) GetCacheBatch(c context.Context, key []K, timeout time.
err = er
return
}
for k, v := range r {
m.Set(c, k, v)
if i, ok := needIndex[k]; ok {
res[i] = v
delete(needIndex, k)
}
}
for k, i := range needIndex {
v, ok := m.Get(c, k)
v, ok := r[k]
if ok {
res[i] = v
} else {
v, ok = m.Get(c, k)
if ok {
res[i] = v
}
}
}
}