MCPcopy Create free account
hub / github.com/cortexproject/cortex / Fetch

Method Fetch

pkg/chunk/cache/tiered.go:28–63  ·  view source on GitHub ↗
(ctx context.Context, keys []string)

Source from the content-addressed store, hash-verified

26}
27
28func (t tiered) Fetch(ctx context.Context, keys []string) ([]string, [][]byte, []string) {
29 found := make(map[string][]byte, len(keys))
30 missing := keys
31 previousCaches := make([]Cache, 0, len(t))
32
33 for _, c := range []Cache(t) {
34 var (
35 passKeys []string
36 passBufs [][]byte
37 )
38
39 passKeys, passBufs, missing = c.Fetch(ctx, missing)
40 tiered(previousCaches).Store(ctx, passKeys, passBufs)
41
42 for i, key := range passKeys {
43 found[key] = passBufs[i]
44 }
45
46 if len(missing) == 0 {
47 break
48 }
49
50 previousCaches = append(previousCaches, c)
51 }
52
53 resultKeys := make([]string, 0, len(found))
54 resultBufs := make([][]byte, 0, len(found))
55 for _, key := range keys {
56 if buf, ok := found[key]; ok {
57 resultKeys = append(resultKeys, key)
58 resultBufs = append(resultBufs, buf)
59 }
60 }
61
62 return resultKeys, resultBufs, missing
63}
64
65func (t tiered) Stop() {
66 for _, c := range []Cache(t) {

Callers

nothing calls this directly

Calls 3

tieredTypeAlias · 0.85
FetchMethod · 0.65
StoreMethod · 0.65

Tested by

no test coverage detected