Redis批量导入数据

首先准备数据文件 格式为

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

利用shell转换数据

#!/bin/bash

while read CMD; do
  # each command begins with *{number arguments in command}

  XS=($CMD); printf "*${#XS[@]}
"
  # for each argument, we append ${length}
{argument}

  for X in $CMD; do printf "$${#X}
$X
"; done
done

转换命令

tool.sh input.data > output.data

然后导入到redis中

cat output.data  | redis-cli --pipe

如果只能在win服务器上连接内网的redis服务器 可以使用

type outpuf.data | redis-cli.exe -h "127.0.0.1" -p 6379 -a password  --pipe
原文地址:https://www.cnblogs.com/toumingbai/p/5990018.html