Skip to content

[Other]: In the GetGroupMembersInfoFunc method, is missingKeys implemented incorrectly? #1075

@hellockl

Description

@hellockl

What would you like to share?

func (g *Group) GetGroupMembersInfoFunc(ctx context.Context, groupID string, userIDs []string,
fetchFunc func(ctx context.Context, missingKeys []string) ([]*model_struct.LocalGroupMember, error),
) (map[string]*model_struct.LocalGroupMember, error) {
var (
res = make(map[string]*model_struct.LocalGroupMember)
missingKeys []string
)

for _, userID := range userIDs {
	key := g.buildGroupMemberKey(groupID, userID)
	if member, ok := g.groupMemberCache.Load(key); ok {
		res[userID] = member
	} else {
		//missingKeys = append(missingKeys, userIDs...)
		missingKeys = append(missingKeys, userID)
	}
}

log.ZDebug(ctx, "GetGroupMembersInfoFunc fetch", "missingKeys", missingKeys)
fetchData, err := fetchFunc(ctx, missingKeys)
if err != nil {
	return nil, err
}

for i, data := range fetchData {
	key := g.buildGroupMemberKey(groupID, data.UserID)
	res[data.UserID] = fetchData[i]
	g.groupMemberCache.Store(key, fetchData[i])
}

return res, nil

}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions