发布于 2021-12-09 16:52:03
这可以通过redis-cli来完成,就像标准的质量插入一样。
$ cat data.txt
JSON.SET foo . '{"bar": "baz"}'
JSON.SET yo . '{"bar": "biz"}'
$ cat data.txt | redis-cli --pipe
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 2
$ redis-cli JSON.GET yo
"{\"bar\":\"biz\"}"如果您希望通过python执行此操作,请使用Redis管道,示例在驱动程序的docs脚本上。
我通常会做这样的事情:
rj = Client(host='localhost', port=6379, decode_responses=True)
pipe = rj.pipeline()
row_count = 0
for x in mydata:
pipe.jsonset(x[0], Path('.cost'), x[1])
row_count += 1
if row_count % 500 == 0:
pipe.execute()
pipe.execute()https://stackoverflow.com/questions/70290512
复制相似问题