Skip to content

Commit

Permalink
fix: return empty for empty tag request
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Nov 25, 2024
1 parent a5d5e62 commit 992ff96
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/tag/cache_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ func (r cacheRepo) Get(ctx context.Context, id model.SubjectID) ([]Tag, error) {

func (r cacheRepo) GetByIDs(ctx context.Context, ids []model.SubjectID) (map[model.SubjectID][]Tag, error) {
var tags []cachedTags
result := make(map[model.SubjectID][]Tag, len(ids))
if len(ids) == 0 {
return result, nil
}

err := r.cache.MGet(ctx, lo.Map(ids, func(item model.SubjectID, index int) string {
return cachekey.SubjectMetaTag(item)
}), &tags)
if err != nil {
return nil, errgo.Wrap(err, "cache.MGet")
}

result := make(map[model.SubjectID][]Tag, len(ids))
for _, tag := range tags {
result[tag.ID] = tag.Tags
}
Expand Down

0 comments on commit 992ff96

Please sign in to comment.