peterbourgon / diskv

A disk-backed key-value store.
http://godoc.org/github.com/peterbourgon/diskv
MIT License
1.41k stars 102 forks source link

ReadStream: never siphon if CacheMaxSize <= 0 #21

Closed jonboulle closed 9 years ago

jonboulle commented 9 years ago

If the user has not set a CacheMaxSize >0, we should never attempt to start siphoning values while reading objects.

@peterbourgon This is the absolutely minimally invasive change I could come up with to implement this without various other knock-on changes (for example, tweaking the Compression interfaces to work with ReadClosers, etc). It's a little weird to have to introduce the closingReader but I did it that way to essentially preserve the same behaviour of the siphon closing the file on EOF.

An alternative would be changing the ReadStream interface to return a ReadCloser, and insist that the user closes the object when done with it (and that would close the underlying file). Not sure how you feel about going in that direction.

jonboulle commented 9 years ago

@peterbourgon updated.

peterbourgon commented 9 years ago

Thanks for the contribution! :100: