From b093947d84127789e5a3a662a9e11d0b9438180e Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 7 Sep 2023 15:58:37 +0100 Subject: [chore] much improved paging package (#2182) --- internal/cache/slice.go | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'internal/cache') diff --git a/internal/cache/slice.go b/internal/cache/slice.go index e296a3b57..5e7fa6ce1 100644 --- a/internal/cache/slice.go +++ b/internal/cache/slice.go @@ -49,28 +49,3 @@ func (c *SliceCache[T]) Load(key string, load func() ([]T, error)) ([]T, error) // Return data clone for safety. return slices.Clone(data), nil } - -// LoadRange is functionally the same as .Load(), but will pass the result through provided reslice function before returning a cloned result. -func (c *SliceCache[T]) LoadRange(key string, load func() ([]T, error), reslice func([]T) []T) ([]T, error) { - // Look for follow IDs list in cache under this key. - data, ok := c.Get(key) - - if !ok { - var err error - - // Not cached, load! - data, err = load() - if err != nil { - return nil, err - } - - // Store the data. - c.Set(key, data) - } - - // Reslice to range. - slice := reslice(data) - - // Return range clone for safety. - return slices.Clone(slice), nil -} -- cgit v1.2.3