This commit is contained in:
xing 2023-11-07 15:39:38 +08:00
parent f6a5cf4255
commit 7978e9ee74

4
cache/map.go vendored
View File

@ -147,13 +147,13 @@ func (m *MapCache[K, V]) GetBatchToMap(c context.Context, key []K, timeout time.
} }
func (m *MapCache[K, V]) getBatchToMap(e Expend[K, V]) func(c context.Context, key []K, timeout time.Duration, params ...any) (map[K]V, error) { func (m *MapCache[K, V]) getBatchToMap(e Expend[K, V]) func(c context.Context, key []K, timeout time.Duration, params ...any) (map[K]V, error) {
return func(ctx context.Context, key []K, timeout time.Duration, params ...any) (map[K]V, error) { return func(ctx context.Context, key []K, timeout time.Duration, params ...any) (map[K]V, error) {
var res = make(map[K]V) var res map[K]V
var needIndex = make(map[K]int)
var err error var err error
mm, err := e.Gets(ctx, key) mm, err := e.Gets(ctx, key)
if err != nil || len(key) == len(mm) { if err != nil || len(key) == len(mm) {
return mm, err return mm, err
} }
var needIndex = make(map[K]int)
res = mm res = mm
var flushKeys []K var flushKeys []K
for i, k := range key { for i, k := range key {