mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-05 21:23:15 -06:00
remove zero checks in uncached key load functions (go-structr now handles this)
This commit is contained in:
parent
83d8b0680a
commit
bca5e1b926
20 changed files with 21 additions and 167 deletions
|
|
@ -64,15 +64,8 @@ func (a *accountDB) GetAccountsByIDs(ctx context.Context, ids []string) ([]*gtsm
|
||||||
accounts, err := a.state.Caches.DB.Account.LoadIDs("ID",
|
accounts, err := a.state.Caches.DB.Account.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Account, error) {
|
func(uncached []string) ([]*gtsmodel.Account, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached accounts.
|
// Preallocate expected length of uncached accounts.
|
||||||
accounts := make([]*gtsmodel.Account, 0, count)
|
accounts := make([]*gtsmodel.Account, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) account IDs.
|
// the remaining (uncached) account IDs.
|
||||||
|
|
|
||||||
|
|
@ -147,15 +147,8 @@ func (a *applicationDB) GetAllTokens(ctx context.Context) ([]*gtsmodel.Token, er
|
||||||
tokens, err := a.state.Caches.DB.Token.LoadIDs("ID",
|
tokens, err := a.state.Caches.DB.Token.LoadIDs("ID",
|
||||||
tokenIDs,
|
tokenIDs,
|
||||||
func(uncached []string) ([]*gtsmodel.Token, error) {
|
func(uncached []string) ([]*gtsmodel.Token, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached tokens.
|
// Preallocate expected length of uncached tokens.
|
||||||
tokens := make([]*gtsmodel.Token, 0, count)
|
tokens := make([]*gtsmodel.Token, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) token IDs.
|
// the remaining (uncached) token IDs.
|
||||||
|
|
|
||||||
|
|
@ -188,15 +188,8 @@ func (c *conversationDB) getConversationsByLastStatusIDs(
|
||||||
accountID,
|
accountID,
|
||||||
conversationLastStatusIDs,
|
conversationLastStatusIDs,
|
||||||
func(accountID string, uncached []string) ([]*gtsmodel.Conversation, error) {
|
func(accountID string, uncached []string) ([]*gtsmodel.Conversation, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached conversations.
|
// Preallocate expected length of uncached conversations.
|
||||||
conversations := make([]*gtsmodel.Conversation, 0, count)
|
conversations := make([]*gtsmodel.Conversation, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning the remaining (uncached) IDs.
|
// Perform database query scanning the remaining (uncached) IDs.
|
||||||
if err := c.db.NewSelect().
|
if err := c.db.NewSelect().
|
||||||
|
|
|
||||||
|
|
@ -586,15 +586,8 @@ func (e *emojiDB) GetEmojisByIDs(ctx context.Context, ids []string) ([]*gtsmodel
|
||||||
emojis, err := e.state.Caches.DB.Emoji.LoadIDs("ID",
|
emojis, err := e.state.Caches.DB.Emoji.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Emoji, error) {
|
func(uncached []string) ([]*gtsmodel.Emoji, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached emojis.
|
// Preallocate expected length of uncached emojis.
|
||||||
emojis := make([]*gtsmodel.Emoji, 0, count)
|
emojis := make([]*gtsmodel.Emoji, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
@ -657,15 +650,8 @@ func (e *emojiDB) GetEmojiCategoriesByIDs(ctx context.Context, ids []string) ([]
|
||||||
categories, err := e.state.Caches.DB.EmojiCategory.LoadIDs("ID",
|
categories, err := e.state.Caches.DB.EmojiCategory.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.EmojiCategory, error) {
|
func(uncached []string) ([]*gtsmodel.EmojiCategory, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached categories.
|
// Preallocate expected length of uncached categories.
|
||||||
categories := make([]*gtsmodel.EmojiCategory, 0, count)
|
categories := make([]*gtsmodel.EmojiCategory, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,7 @@ func (f *filterDB) GetFiltersForAccountID(ctx context.Context, accountID string)
|
||||||
filters, err := f.state.Caches.DB.Filter.LoadIDs("ID",
|
filters, err := f.state.Caches.DB.Filter.LoadIDs("ID",
|
||||||
filterIDs,
|
filterIDs,
|
||||||
func(uncached []string) ([]*gtsmodel.Filter, error) {
|
func(uncached []string) ([]*gtsmodel.Filter, error) {
|
||||||
// Avoid querying
|
filters := make([]*gtsmodel.Filter, 0, len(uncached))
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
filters := make([]*gtsmodel.Filter, 0, count)
|
|
||||||
if err := f.db.
|
if err := f.db.
|
||||||
NewSelect().
|
NewSelect().
|
||||||
Model(&filters).
|
Model(&filters).
|
||||||
|
|
|
||||||
|
|
@ -113,14 +113,8 @@ func (f *filterDB) getFilterKeywords(ctx context.Context, idColumn string, id st
|
||||||
filterKeywords, err := f.state.Caches.DB.FilterKeyword.LoadIDs("ID",
|
filterKeywords, err := f.state.Caches.DB.FilterKeyword.LoadIDs("ID",
|
||||||
filterKeywordIDs,
|
filterKeywordIDs,
|
||||||
func(uncached []string) ([]*gtsmodel.FilterKeyword, error) {
|
func(uncached []string) ([]*gtsmodel.FilterKeyword, error) {
|
||||||
// Avoid querying
|
filterKeywords := make([]*gtsmodel.FilterKeyword, 0, len(uncached))
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
filterKeywords := make([]*gtsmodel.FilterKeyword, 0, count)
|
|
||||||
if err := f.db.
|
if err := f.db.
|
||||||
NewSelect().
|
NewSelect().
|
||||||
Model(&filterKeywords).
|
Model(&filterKeywords).
|
||||||
|
|
|
||||||
|
|
@ -100,14 +100,7 @@ func (f *filterDB) getFilterStatuses(ctx context.Context, idColumn string, id st
|
||||||
filterStatuses, err := f.state.Caches.DB.FilterStatus.LoadIDs("ID",
|
filterStatuses, err := f.state.Caches.DB.FilterStatus.LoadIDs("ID",
|
||||||
filterStatusIDs,
|
filterStatusIDs,
|
||||||
func(uncached []string) ([]*gtsmodel.FilterStatus, error) {
|
func(uncached []string) ([]*gtsmodel.FilterStatus, error) {
|
||||||
// Avoid querying
|
filterStatuses := make([]*gtsmodel.FilterStatus, 0, len(uncached))
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
filterStatuses := make([]*gtsmodel.FilterStatus, 0, count)
|
|
||||||
if err := f.db.
|
if err := f.db.
|
||||||
NewSelect().
|
NewSelect().
|
||||||
Model(&filterStatuses).
|
Model(&filterStatuses).
|
||||||
|
|
|
||||||
|
|
@ -325,15 +325,8 @@ func (l *listDB) GetListsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.L
|
||||||
lists, err := l.state.Caches.DB.List.LoadIDs("ID",
|
lists, err := l.state.Caches.DB.List.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.List, error) {
|
func(uncached []string) ([]*gtsmodel.List, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached lists.
|
// Preallocate expected length of uncached lists.
|
||||||
lists := make([]*gtsmodel.List, 0, count)
|
lists := make([]*gtsmodel.List, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -57,15 +57,8 @@ func (m *mediaDB) GetAttachmentsByIDs(ctx context.Context, ids []string) ([]*gts
|
||||||
media, err := m.state.Caches.DB.Media.LoadIDs("ID",
|
media, err := m.state.Caches.DB.Media.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.MediaAttachment, error) {
|
func(uncached []string) ([]*gtsmodel.MediaAttachment, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached media attachments.
|
// Preallocate expected length of uncached media attachments.
|
||||||
media := make([]*gtsmodel.MediaAttachment, 0, count)
|
media := make([]*gtsmodel.MediaAttachment, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -69,15 +69,8 @@ func (m *mentionDB) GetMentions(ctx context.Context, ids []string) ([]*gtsmodel.
|
||||||
mentions, err := m.state.Caches.DB.Mention.LoadIDs("ID",
|
mentions, err := m.state.Caches.DB.Mention.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Mention, error) {
|
func(uncached []string) ([]*gtsmodel.Mention, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached mentions.
|
// Preallocate expected length of uncached mentions.
|
||||||
mentions := make([]*gtsmodel.Mention, 0, count)
|
mentions := make([]*gtsmodel.Mention, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -107,15 +107,8 @@ func (n *notificationDB) GetNotificationsByIDs(ctx context.Context, ids []string
|
||||||
notifs, err := n.state.Caches.DB.Notification.LoadIDs("ID",
|
notifs, err := n.state.Caches.DB.Notification.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Notification, error) {
|
func(uncached []string) ([]*gtsmodel.Notification, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached notifications.
|
// Preallocate expected length of uncached notifications.
|
||||||
notifs := make([]*gtsmodel.Notification, 0, count)
|
notifs := make([]*gtsmodel.Notification, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -274,15 +274,8 @@ func (p *pollDB) GetPollVotes(ctx context.Context, pollID string) ([]*gtsmodel.P
|
||||||
votes, err := p.state.Caches.DB.PollVote.LoadIDs("ID",
|
votes, err := p.state.Caches.DB.PollVote.LoadIDs("ID",
|
||||||
voteIDs,
|
voteIDs,
|
||||||
func(uncached []string) ([]*gtsmodel.PollVote, error) {
|
func(uncached []string) ([]*gtsmodel.PollVote, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached votes.
|
// Preallocate expected length of uncached votes.
|
||||||
votes := make([]*gtsmodel.PollVote, 0, count)
|
votes := make([]*gtsmodel.PollVote, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -105,15 +105,8 @@ func (r *relationshipDB) GetBlocksByIDs(ctx context.Context, ids []string) ([]*g
|
||||||
blocks, err := r.state.Caches.DB.Block.LoadIDs("ID",
|
blocks, err := r.state.Caches.DB.Block.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Block, error) {
|
func(uncached []string) ([]*gtsmodel.Block, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached blocks.
|
// Preallocate expected length of uncached blocks.
|
||||||
blocks := make([]*gtsmodel.Block, 0, count)
|
blocks := make([]*gtsmodel.Block, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -82,15 +82,8 @@ func (r *relationshipDB) GetFollowsByIDs(ctx context.Context, ids []string) ([]*
|
||||||
follows, err := r.state.Caches.DB.Follow.LoadIDs("ID",
|
follows, err := r.state.Caches.DB.Follow.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Follow, error) {
|
func(uncached []string) ([]*gtsmodel.Follow, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached follows.
|
// Preallocate expected length of uncached follows.
|
||||||
follows := make([]*gtsmodel.Follow, 0, count)
|
follows := make([]*gtsmodel.Follow, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -81,15 +81,8 @@ func (r *relationshipDB) GetFollowRequestsByIDs(ctx context.Context, ids []strin
|
||||||
follows, err := r.state.Caches.DB.FollowRequest.LoadIDs("ID",
|
follows, err := r.state.Caches.DB.FollowRequest.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.FollowRequest, error) {
|
func(uncached []string) ([]*gtsmodel.FollowRequest, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached followReqs.
|
// Preallocate expected length of uncached followReqs.
|
||||||
follows := make([]*gtsmodel.FollowRequest, 0, count)
|
follows := make([]*gtsmodel.FollowRequest, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -87,15 +87,8 @@ func (r *relationshipDB) getMutesByIDs(ctx context.Context, ids []string) ([]*gt
|
||||||
mutes, err := r.state.Caches.DB.UserMute.LoadIDs("ID",
|
mutes, err := r.state.Caches.DB.UserMute.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.UserMute, error) {
|
func(uncached []string) ([]*gtsmodel.UserMute, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached mutes.
|
// Preallocate expected length of uncached mutes.
|
||||||
mutes := make([]*gtsmodel.UserMute, 0, count)
|
mutes := make([]*gtsmodel.UserMute, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,8 @@ func (s *statusDB) GetStatusesByIDs(ctx context.Context, ids []string) ([]*gtsmo
|
||||||
statuses, err := s.state.Caches.DB.Status.LoadIDs("ID",
|
statuses, err := s.state.Caches.DB.Status.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Status, error) {
|
func(uncached []string) ([]*gtsmodel.Status, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached statuses.
|
// Preallocate expected length of uncached statuses.
|
||||||
statuses := make([]*gtsmodel.Status, 0, count)
|
statuses := make([]*gtsmodel.Status, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) status IDs.
|
// the remaining (uncached) status IDs.
|
||||||
|
|
|
||||||
|
|
@ -73,15 +73,8 @@ func (s *statusBookmarkDB) GetStatusBookmarksByIDs(ctx context.Context, ids []st
|
||||||
bookmarks, err := s.state.Caches.DB.StatusBookmark.LoadIDs("ID",
|
bookmarks, err := s.state.Caches.DB.StatusBookmark.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.StatusBookmark, error) {
|
func(uncached []string) ([]*gtsmodel.StatusBookmark, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached bookmarks.
|
// Preallocate expected length of uncached bookmarks.
|
||||||
bookmarks := make([]*gtsmodel.StatusBookmark, 0, count)
|
bookmarks := make([]*gtsmodel.StatusBookmark, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) bookmarks.
|
// the remaining (uncached) bookmarks.
|
||||||
|
|
|
||||||
|
|
@ -133,15 +133,8 @@ func (s *statusFaveDB) GetStatusFaves(ctx context.Context, statusID string) ([]*
|
||||||
faves, err := s.state.Caches.DB.StatusFave.LoadIDs("ID",
|
faves, err := s.state.Caches.DB.StatusFave.LoadIDs("ID",
|
||||||
faveIDs,
|
faveIDs,
|
||||||
func(uncached []string) ([]*gtsmodel.StatusFave, error) {
|
func(uncached []string) ([]*gtsmodel.StatusFave, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached faves.
|
// Preallocate expected length of uncached faves.
|
||||||
faves := make([]*gtsmodel.StatusFave, 0, count)
|
faves := make([]*gtsmodel.StatusFave, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) fave IDs.
|
// the remaining (uncached) fave IDs.
|
||||||
|
|
|
||||||
|
|
@ -80,15 +80,8 @@ func (t *tagDB) GetTags(ctx context.Context, ids []string) ([]*gtsmodel.Tag, err
|
||||||
tags, err := t.state.Caches.DB.Tag.LoadIDs("ID",
|
tags, err := t.state.Caches.DB.Tag.LoadIDs("ID",
|
||||||
ids,
|
ids,
|
||||||
func(uncached []string) ([]*gtsmodel.Tag, error) {
|
func(uncached []string) ([]*gtsmodel.Tag, error) {
|
||||||
// Avoid querying
|
|
||||||
// if none uncached.
|
|
||||||
count := len(uncached)
|
|
||||||
if count == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preallocate expected length of uncached tags.
|
// Preallocate expected length of uncached tags.
|
||||||
tags := make([]*gtsmodel.Tag, 0, count)
|
tags := make([]*gtsmodel.Tag, 0, len(uncached))
|
||||||
|
|
||||||
// Perform database query scanning
|
// Perform database query scanning
|
||||||
// the remaining (uncached) IDs.
|
// the remaining (uncached) IDs.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue