Write implements backend.Writer
(ctx context.Context, name string, keypath backend.KeyPath, data io.Reader, size int64, cacheInfo *backend.CacheInfo)
| 137 | |
| 138 | // Write implements backend.Writer |
| 139 | func (r *readerWriter) Write(ctx context.Context, name string, keypath backend.KeyPath, data io.Reader, size int64, cacheInfo *backend.CacheInfo) error { |
| 140 | b, err := tempo_io.ReadAllWithEstimate(data, size) |
| 141 | if err != nil { |
| 142 | return err |
| 143 | } |
| 144 | |
| 145 | if cache := r.cacheFor(cacheInfo); cache != nil { |
| 146 | cache.Store(ctx, []string{key(keypath, name)}, [][]byte{b}) |
| 147 | } |
| 148 | |
| 149 | // previous implemenation always passed false forward for "shouldCache" so we are matching that behavior by passing nil for cacheInfo |
| 150 | // todo: reevaluate. should we pass the cacheInfo forward? |
| 151 | return r.nextWriter.Write(ctx, name, keypath, bytes.NewReader(b), int64(len(b)), nil) |
| 152 | } |
| 153 | |
| 154 | // Append implements backend.Writer |
| 155 | func (r *readerWriter) Append(ctx context.Context, name string, keypath backend.KeyPath, tracker backend.AppendTracker, buffer []byte) (backend.AppendTracker, error) { |