diff options
author | 2023-09-07 15:58:37 +0100 | |
---|---|---|
committer | 2023-09-07 15:58:37 +0100 | |
commit | b093947d84127789e5a3a662a9e11d0b9438180e (patch) | |
tree | eec3be2f1594599bee3db90e737431708101ae45 /internal/cache/slice.go | |
parent | [feature] Support OTLP HTTP, drop Jaeger (#2184) (diff) | |
download | gotosocial-b093947d84127789e5a3a662a9e11d0b9438180e.tar.xz |
[chore] much improved paging package (#2182)
Diffstat (limited to 'internal/cache/slice.go')
-rw-r--r-- | internal/cache/slice.go | 25 |
1 files changed, 0 insertions, 25 deletions
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 -} |