bsm / redeo

High-performance framework for building redis-protocol compatible TCP servers/services
Apache License 2.0
438 stars 39 forks source link

Double-quoted string shoud be treated as one argument #18

Closed zsimple closed 6 years ago

zsimple commented 6 years ago

Very sweet library, thanks!

I found a litte problem when I want use it in my project: If I type echo "hello world", c.ArgN() returns 2 rather then 1, redis do the right thing. Maybe it's better to parse double-quoted string as one argument rather then just split them by blank?

dim commented 6 years ago

@zsimple sorry, I am not following:

$ redis-cli -p 9736 echo "hello world"
"hello world"

You can even add some debug to https://github.com/bsm/redeo/blob/master/redeo.go#L49, e.g. fmt.Println(len(c.Args), c.Args) outputs 1 [hello world] for me.

dim commented 6 years ago

Right, I think I see now:

$ (printf "echo \"hello world\"\r\n"; sleep 1) | nc localhost 6379
$11
hello world
$ (printf "echo \"hello world\"\r\n"; sleep 1) | nc localhost 9736
-ERR wrong number of arguments for 'echo' command
-ERR EOF
dim commented 6 years ago

see #19

zsimple commented 6 years ago

Thanks very much again! It is really a useful library.

dim commented 6 years ago

Thanks, you can also check out https://github.com/bsm/redeoraft and https://github.com/bsm/planb if you are looking for clustering