GetMultiWithError implements Cache.
(ctx context.Context, keys []string, opts ...Option)
| 103 | |
| 104 | // GetMultiWithError implements Cache. |
| 105 | func (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. |
| 126 | func (s *SnappyCache) Stop() { |
no test coverage detected