Bash function to translate redis commands to their pipelined equivalent
Bash function to translate redis commands to their pipelined equivalent
eg.
$ redis_p HMSET key value key1 value1
*5
$5
HMSET
$3
key
$5
value
$4
key1
$6
value1
$
function redis_p() {
declare ARR=(${@:-$(</dev/stdin)})
OUTPUT="*${#ARR[@]}\r\n"
for a in "${ARR[@]}"; do
OUTPUT+="\$${#a}\r\n${a}\r\n"
done
echo -ne $"${OUTPUT}"
}```
Written by Ruiwen Chua
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#