Mass Delete redis-cli pipe mode

658 views
Skip to first unread message

Salimane Adjao Moustapha

unread,
Oct 30, 2012, 3:46:22 AM10/30/12
to redi...@googlegroups.com
With the redis-cli pipe mode in 2.6 i tried to perform some mass delete but got some errors:

redis-cli --version            
redis-cli 2.6.2 (git:0dd62413)

cat keys.txt       
DEL "hello:sam:ffe947d8f38294bbe803ee215ce86a0c1351174734570"
DEL "hello:sam:ffe947afe1f5a77bb1321678c5c6fead1349924630583"
DEL "hello:sam:ffe9479eed8a7937b706c08fec49ebf71350532203343"
DEL "hello:sam:ffe94791cd8a220638d6049a9c38e1471347726367359"

cat keys.txt | redis-cli --pipe
All data transferred. Waiting for the last reply...
ERR unknown command '$4'
ERR wrong number of arguments for 'echo' command
ERR unknown command '$20'
ERR unknown command 'H�7 3^�6R���g:Ʉ�'

the following has no errors but doesn't delete any keys : 

cat keys.txt | xargs redis-cli --pipe
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 0

The following do work though :

cat keys.txt | redis-cli  
(integer) 0
(integer) 1
(integer) 1
(integer) 0


cat keys.txt | xargs redis-cli
(integer) 2

I'm trying not use the later 2 because of round trips and memory (I'm talking around 100 millions keys). So if pipe mode is designed for this, why is it not working ?

Thanks





Didier Spezia

unread,
Oct 30, 2012, 4:00:43 AM10/30/12
to redi...@googlegroups.com

>> I'm trying not use the later 2 because of round trips and memory (I'm talking around 100 millions keys). So if pipe mode is designed for this, why is it not working ?


The --pipe mode input is supposed to be Redis protocol, not text commands.

You need to use something like this:
echo -n '*2\r\n$3\r\nDEL\r\n$4\r\ntoto\r\n' | ./redis-cli --pipe

Regards,
Didier.



Reply all
Reply to author
Forward
0 new messages