You can check the following points.
First, the line separator in the Redis protocol is \ r \ n (and not just \ n). Therefore, you must be sure that your input file contains these characters.
Then netcat disconnects the connection at the end of the input file (therefore, it may not wait for Redis to respond). This probably depends on the version of netcat. In my system:
$ od -c toto.txt 0000000 * 3 \n $ 3 \n SET \n $ 4 \nkey 0000020 1 \n $ 6 \nvalue 1 \n * 3 \n $ 0000040 3 \n SET \n $ 4 \nkey 2 \n $ 6 0000060 \nvalue 2 \n $ ( sed 's/$/\r/' < toto.txt ; sleep 1 ) | netcat localhost 6379 +OK +OK
An extra second gives netcat the opportunity to read the Redis answer.
Note that redis-cli in -pipe mode is much better than netcat for performing massive injections through the Redis protocol.
source share