You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reader functions String() and Bytes() and thus Result.Scan(Scanner) currently only supports returning values when tokenLen < buf.Size() the problem is obviously that this is a bit obscure. Should this be documented as an "expected behaviour" and steer people to use Result.Scan(io.Writer) instead (and throw appropriate error messages) or should we implement support for size up to Redis max size?
The first way would encourage "good behaviour", as in that it makes people think about how much memory they're allocating (and thus copying) and steer them to using various buffers (such as strings.Builder{} or bytes.Buffer{}) rather than "blindly" use the primitive types. The second would allow people to shoot themselves in the foot if they want to, and many people may want that. 🤔
I'm currently leaning towards throwing errors and encourage good behaviour as I'm a bit of a Good Samaritan in that sense.
The text was updated successfully, but these errors were encountered:
mikn
changed the title
Should Reader.String() etc (implemented through Peek) support "unlimited size"?
Should Reader.String() etc support "unlimited size"?
Aug 24, 2020
Currently the code implements neither approach and would permanently mess up the state of the connection if it were to encounter a situation where it couldn't call Peek() to read the full token. With the redesign of the internals, surfacing a relevant error should be significantly easier.
mikn
changed the title
Should Reader.String() etc support "unlimited size"?
Reader.String()/Bytes()/Int() should return an error if Peek() fails rather than destroy the connection state
Apr 22, 2021
Reader functions
String()
andBytes()
and thusResult.Scan(Scanner)
currently only supports returning values whentokenLen < buf.Size()
the problem is obviously that this is a bit obscure. Should this be documented as an "expected behaviour" and steer people to useResult.Scan(io.Writer)
instead (and throw appropriate error messages) or should we implement support for size up to Redis max size?The first way would encourage "good behaviour", as in that it makes people think about how much memory they're allocating (and thus copying) and steer them to using various buffers (such as
strings.Builder{}
orbytes.Buffer{}
) rather than "blindly" use the primitive types. The second would allow people to shoot themselves in the foot if they want to, and many people may want that. 🤔I'm currently leaning towards throwing errors and encourage good behaviour as I'm a bit of a Good Samaritan in that sense.
The text was updated successfully, but these errors were encountered: