redis-pipe:像Unix Pipes一樣對待 Redis Lists
redis-pipe可以讓你處理Redis的列表,好像他們是Unix的管道。它基本上是利用LPUSH和LPOP連接 stdin 與 stdout。
How it works
Configuration
Set theREDIS_HOSTandREDIS_PORTenvironment variables for easy configuration or pass--hostand--portarguments.
Writing from stdin to Redis List
Pipe in value toredis-pipeand it willLPUSHthem to the Redis List.
echo "hi there" | ./redis-pipe greetings
Reading from Redis List to stdout
If you callredis-pipewith a tty attached it willLPOPall values from the Redis List and write them to stdout.
./redis-pipe greetings
You can also limit the amount of values popped from the list.
./redis-pipe --count 100 greetings
Support for blocking mode withBLPOPis not supported yet.
Examples
Centralized Logging
In this sample we pipe the syslog to a Redis List calledlogs.
tail -f /var/log/syslog | ./redis-pipe logs
You can now easily collect all the syslogs of your machines on a single server.
./redis-pipe logs > logs.txt
Very basic job queue
Create jobs and store them.
cat jobs.txt | ./redis-pipe jobs
Process jobs on several workers and store the results.
./redis-pipe --count 10 jobs | python do-work.py | ./redis-pipe results
Collect the results.
./redis-pipe results > results.txt
本文由用戶 cm54 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!