我使用telnet输入这样的命令行命令

get field with spaces
get "field with spaces"
get 'field with spaces'

所有这三个返回相同的错误。
-ERR wrong number of arguments for 'get' command

最佳答案

如果只有telnet(而不是'redis-cli'),则需要使用Redis二进制安全统一协议(protocol)在键名中使用空格,例如:

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二进制安全协议(protocol)的更多信息:http://redis.io/topics/protocol

10-06 15:16