diff options
author | 2024-04-02 11:03:40 +0100 | |
---|---|---|
committer | 2024-04-02 12:03:40 +0200 | |
commit | adf345f1ec0cb76a0df94a4505143d891659cba9 (patch) | |
tree | e0cca289c0a50f30191d4b65a2c336704570e470 /internal/db/bundb/list.go | |
parent | [feature] Option to hide followers/following (#2788) (diff) | |
download | gotosocial-adf345f1ec0cb76a0df94a4505143d891659cba9.tar.xz |
[chore] bump go structr cache version -> v0.6.0 (#2773)
* update go-structr library -> v0.6.0, add necessary wrapping types + code changes to support these changes
* update readme with go-structr package changes
* improved wrapping of the SliceCache type
* add code comments for the cache wrapper types
* remove test.out :innocent:
---------
Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
Diffstat (limited to 'internal/db/bundb/list.go')
-rw-r--r-- | internal/db/bundb/list.go | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/internal/db/bundb/list.go b/internal/db/bundb/list.go index fb97c8fe7..92936a49f 100644 --- a/internal/db/bundb/list.go +++ b/internal/db/bundb/list.go @@ -341,23 +341,10 @@ func (l *listDB) GetListEntries(ctx context.Context, } func (l *listDB) GetListsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.List, error) { - // Preallocate at-worst possible length. - uncached := make([]string, 0, len(ids)) - // Load all list IDs via cache loader callbacks. - lists, err := l.state.Caches.GTS.List.Load("ID", - - // Load cached + check for uncached. - func(load func(keyParts ...any) bool) { - for _, id := range ids { - if !load(id) { - uncached = append(uncached, id) - } - } - }, - - // Uncached list loader function. - func() ([]*gtsmodel.List, error) { + lists, err := l.state.Caches.GTS.List.LoadIDs("ID", + ids, + func(uncached []string) ([]*gtsmodel.List, error) { // Preallocate expected length of uncached lists. lists := make([]*gtsmodel.List, 0, len(uncached)) @@ -401,23 +388,10 @@ func (l *listDB) GetListsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.L } func (l *listDB) GetListEntriesByIDs(ctx context.Context, ids []string) ([]*gtsmodel.ListEntry, error) { - // Preallocate at-worst possible length. - uncached := make([]string, 0, len(ids)) - // Load all entry IDs via cache loader callbacks. - entries, err := l.state.Caches.GTS.ListEntry.Load("ID", - - // Load cached + check for uncached. - func(load func(keyParts ...any) bool) { - for _, id := range ids { - if !load(id) { - uncached = append(uncached, id) - } - } - }, - - // Uncached entry loader function. - func() ([]*gtsmodel.ListEntry, error) { + entries, err := l.state.Caches.GTS.ListEntry.LoadIDs("ID", + ids, + func(uncached []string) ([]*gtsmodel.ListEntry, error) { // Preallocate expected length of uncached entries. entries := make([]*gtsmodel.ListEntry, 0, len(uncached)) |