I have been looking all over SO for a working solution but no luck :/
I want to perform the mass insertion using the pipelining
feature of redis-cli
but I am not able to do so.
I have a JAVA code snippet which create a file containing all the commands to run.
String add = "*4\r\n$4\r\nHSET\r\n$22\r\ndiscountProgramOffers\r\n$" +
key.getBytes().length + "\r\n" + key + "\r\n$" +
json.getBytes().length + "\r\n" + json + "\r\n";
System.out.println(add);
In the above code, I followed mass insertion link present at Redis Documentation site.
And this is a demo String which is getting created.
*4\r\n$4\r\nHSET\r\n$22\r\ndiscountProgramOffers\r\n$5\r\nmykey\r\n$7\r\nmyvalue\r\n
When I run the file which is created by the snippet, sometimes I get nothing, and sometimes I get this error:
Error writing to the server: Connection reset by peer
EX:
echo -e "$(cat massInsert.txt)" | redis/src/redis-cli --pipe
Error writing to the server: Connection reset by peer
Am I doing something wrong?? Please help.
FYI: I referred to these questions:
If you are doing everything right, but it still does not work, it may be your linux shell's fault and you may need to switch the shell (e.g. to
BusyBox
ash
on Alpine, where Redis is usually conveniently installed, at least in containerized versions).Correctly formed RESP strings should display in full (i.e. with each keyword and key or value name in separate line) when using either of these commands:
Currently I've verified it works either in BusyBox
ash
(linked to/bin/sh
) on Alpine:... while it fails to print correctly RESP files in either shell preinstalled on Ubuntu (so both in
bash
and indash
, to whichsh
is linked on Ubuntu):