Make null implementation of Gitaly pack-objects cache more efficient
In #2222 (closed) and #2223 we have proposals to selectively bypass / disable the Gitaly pack-objects cache. The current interface of the streamcache
internal library forces you to use a pipe and copy data.
FindOrCreate(key string, create func(io.Writer) error) (s *Stream, created bool, err error)
This is because the *Stream
return value is a reader. This is clearly visible in the implementation of streamcache.Null
.
It would be more efficient if the cache took a writer as its argument, rather than returning a reader.
Fetch(ctx context.Context, key string, dst io.Writer, create func(io.Writer) error) (written int64, created bool, err error)
That way, you can trivially implement a null cache: you call create(dst)
, without needing an in between pipe.
Edited by Jacob Vosmaer