我正在使用管道玩Redis mass import,并拥有以下Python脚本:
mydata = ""
mydata += "*4\r\n$4\r\nHSET\r\n$%d\r\n%s\r\n$%d\r\n%s\r\n$%d\r\n%s\r\n" % (len('myhash'), 'myhash', len('myfield'), 'myfield', len('myvalue'), 'myvalue')
print mydata.rstrip()
它产生:
$ python redis_test.py
*4
$4
HSET
$6
myhash
$7
myfield
$7
myvalue
管道输出:
$ python redis_test.py | redis-cli -h rnode -n 5 --pipe --pipe-timeout 1
All data transferred. Waiting for the last reply...
ERR unknown command '2'
ERR unknown command '$4'
ERR wrong number of arguments for 'echo' command
ERR unknown command '$20'
ERR unknown command '�˛�ƩA\m���pm��X�[�'
No replies for 1 seconds: exiting.
errors: 6, replies: 6
虽然我让它填充数据库,我想知道是什么导致这些错误?你知道吗
rnode:6379[5]> keys *
1) "myhash"
rnode:6379[5]> hgetall myhash
1) "myfield"
2) "myvalue"
回答我自己的问题:我不知道它需要一个最终的CRLF,因此:
成为:
结果:
相关问题 更多 >
编程相关推荐