MCPcopy
hub / github.com/grafana/dskit / GetMultiWithError

Method GetMultiWithError

cache/compression.go:105–123  ·  cache/compression.go::SnappyCache.GetMultiWithError

GetMultiWithError implements Cache.

(ctx context.Context, keys []string, opts ...Option)

Source from the content-addressed store, hash-verified

103
104// GetMultiWithError implements Cache.
105func (s *SnappyCache) GetMultiWithError(ctx context.Context, keys []string, opts ...Option) (map[string][]byte, error) {
106 errs := []error{}
107
108 found, err := s.next.GetMultiWithError(ctx, keys, opts...)
109 errs = append(errs, err)
110 decoded := make(map[string][]byte, len(found))
111
112 for key, encodedValue := range found {
113 decodedValue, decodeErr := snappy.Decode(nil, encodedValue)
114 if decodeErr != nil {
115 errs = append(errs, fmt.Errorf("failed to decode cache entry for key %s: %w", key, decodeErr))
116 continue
117 }
118
119 decoded[key] = decodedValue
120 }
121
122 return decoded, errors.Join(errs...)
123}
124
125// Stop implements Cache.
126func (s *SnappyCache) Stop() {

Callers 1

GetMultiMethod · 0.95

Calls 3

ErrorfMethod · 0.80
GetMultiWithErrorMethod · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected