使用telnet我在命令行中键入命令,这样如何使用包含空格的键从Redis获取值?
get field with spaces
get "field with spaces"
get 'field with spaces'
而这一切的三个回程同样的错误。
-ERR wrong number of arguments for 'get' command
使用telnet我在命令行中键入命令,这样如何使用包含空格的键从Redis获取值?
get field with spaces
get "field with spaces"
get 'field with spaces'
而这一切的三个回程同样的错误。
-ERR wrong number of arguments for 'get' command
如果你只有远程登录(而不是“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
您使用的是什么版本的redis?它使用双引号
[email protected]:~# 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>
得到“领域\与\空格”
为我工作工作正常,我在2.2.2。
我没有ssh访问权限。我使用telnet连接。 – user769353 2011-05-27 09:49:45
@ user769353您可以将redis-cli连接到其他主机的Redis服务器,使用-h参数('redis-cli -h 8.8.8.8')! – 2015-10-06 10:51:59