Redis批量导入数据

首先准备数据文件 格式为redis

SET Key0 Value0
SET Key1 Value1
...
SET KeyN ValueN

 

利用shell转换数据shell

#!/bin/bash

while read CMD; do
  # each command begins with *{number arguments in command}\r\n
  XS=($CMD); printf "*${#XS[@]}\r\n"
  # for each argument, we append ${length}\r\n{argument}\r\n
  for X in $CMD; do printf "\$${#X}\r\n$X\r\n"; done
done

转换命令bash

tool.sh input.data > output.data

而后导入到redis中服务器

cat output.data  | redis-cli --pipe

若是只能在win服务器上链接内网的redis服务器 可使用app

type outpuf.data | redis-cli.exe -h "127.0.0.1" -p 6379 -a password  --pipe
相关文章
相关标签/搜索