Seems most commands allow for buffers to be returned using { returnBuffers: true }
This however doesn’t seem to work for the various scan methods. Particularly, I’m trying to use hScanIterator
.
Is there any way to return buffers using hScanIterator
?
2
Answers
I did a spelunk into the code and it looks like it doesn’t support it. That said, I think it should. I’d open an issue and ask for it.
As a workaround, the strings that are returned are parsable to bytes. They use a C-style escaping syntax. I tried to find a library for Node.js that would convert them to bytes to no avail but it certainly wouldn’t be hard to write one. The code that escapes these string in Redis (at least I think this is the code) shows you what you would need to look for and convert in the string.
Perhaps not the answer you were hoping for, but probably as good as it will get until the feature is added. 😉
The built-in scan iterator methods does not support the
returnBuffer
flag (although they should). In the mean time you can implement the iterator youself: