使用telnet我输入这样的命令行命令
get field with spaces
get "field with spaces"
get 'field with spaces'
所有这三个都返回相同的错误。
-ERR wrong number of arguments for 'get' command
答案 0 :(得分:10)
您使用的是哪个版本的redis?它使用双引号
在2.2.2上工作正常root@this:~# redis-cli
redis> set "test space" hello
OK
redis> get "test space"
"hello"
redis> get 'test space'
(error) ERR wrong number of arguments for 'get' command
redis>
答案 1 :(得分:5)
如果您只有telnet(而不是' redis-cli'),那么您需要使用Redis二进制安全统一协议来使用密钥名称中的空格,例如:
telnet localhost 6379
*2
$3
GET
$17
field with spaces
hello (this is Redis answer if "field with spaces" contains value "hello")
Explanation:
*2 = Number of arguments (first arg is "GET" and second is "field with spaces")
$3 = length of first argument ("GET" contains 3 bytes)
$17 = length of second argument ("field with spaces" contains 17 bytes)
有关Redis二进制安全协议的更多信息:http://redis.io/topics/protocol
答案 2 :(得分:0)
获取“field \ with \ spaces”
对我有用。