Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis Mass Insertion - Errors out

Tags:

docker

redis

I'm trying to follow Redis Mass Insertion – Redis with Redis and something is amiss(.

root@f7ca5eef4a4c:~# redis-cli --version   
redis-cli 3.0.6
root@f7ca5eef4a4c:~# redis-cli                                                   
127.0.0.1:6379> flushall
OK
127.0.0.1:6379> 
root@f7ca5eef4a4c:~# for i in {0..10} ; do echo "SET Key$i Value$i" >> $$ ; done 
root@f7ca5eef4a4c:~# cat $$ | redis-cli --pipe                                  
All data transferred. Waiting for the last reply...
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
ERR unknown command 'ET'
Last reply received from server.
errors: 10, replies: 11
root@f7ca5eef4a4c:~# cat $$
SET Key0 Value0
SET Key1 Value1
SET Key2 Value2
SET Key3 Value3
SET Key4 Value4
SET Key5 Value5
SET Key6 Value6
SET Key7 Value7
SET Key8 Value8
SET Key9 Value9
SET Key10 Value10
root@f7ca5eef4a4c:~# 

What am I doing wrong? Why is it failing?

like image 263
alexus Avatar asked Sep 19 '26 22:09

alexus


1 Answers

I think redis is expecting lines terminated by \r or \r\n. If you're doing this on linux, you'll get \n terminated lines, which redis can't parse.

Try this, in the same directory where you entered the other commands:

# rm $$
# for i in {0..10} ; do printf "SET Key$i Value$i\r\n" >> $$ ; done
# cat $$ | redis-cli --pipe

Whoever wrote that tutorial was probably working on Mac or Windows, which happened to produce the appropriate line terminators.

like image 128
panta82 Avatar answered Sep 22 '26 10:09

panta82



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!