Skip to content

Instantly share code, notes, and snippets.

@nicwolff
Last active November 9, 2023 22:59
Show Gist options
  • Save nicwolff/3b585430efe07fc2ef6282725b5b34c1 to your computer and use it in GitHub Desktop.
Save nicwolff/3b585430efe07fc2ef6282725b5b34c1 to your computer and use it in GitHub Desktop.
Pipe commands in Redis format
#!/usr/bin/env 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
@nicwolff
Copy link
Author

nicwolff commented Nov 9, 2023

cat data.csv | sed 's/"//g' | while IFS=, read key value score; do printf "ZADD $key $score $value\n"; done | bin/redis-pipe.sh | time redis-cli -h <redis_host> --pipe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment