Created
April 14, 2015 11:44
-
-
Save lqez/662ab06a230dffc6c142 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
r = redis.StrictRedis(host='localhost') | |
r.delete('queue') | |
# Add work into queue | |
print r.hset('queue', 'file1.mp4', 'will be processed on machine A') | |
# return value will be 1 - a new value | |
# Another machine tries to add same work | |
print r.hset('queue', 'file1.mp4', 'will be processed on machine B') | |
# return value will be 0 - duplicated | |
# Then, tries to add other work | |
print r.hset('queue', 'file2.mp4', 'will be processed on machine B') | |
# return value will be 1 - a new value | |
# Machine A finished file1.mp4 | |
print r.hdel('queue', 'file1.mp4') | |
# return value will be 1 - deleted | |
# Get all jobs from queue | |
print r.hgetall('queue') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment