Joined March 2012
·
Posted to
Writing a queue system in Redis
over 1 year
ago
Looks like I worded that poorly. Since the queue is built on top of a zset, calling zadd will always result in a unique set and a setnx call is no longer necessary. Zadd also has a behavior which I found useful: calling zadd with an existing member updates the member's score and reorders the zset, allowing an event to be "rescheduled" to a different time.
I'll post a writeup later. You can also browse the code here: https://github.com/Erol/later.
Posted to
Writing a queue system in Redis
over 1 year
ago
I wrote a lightweight event scheduling library, and the events/payload added had to be unique and run on a scheduled time. I've managed to avoid the use of setnx by using a zset queue; the zset handles both scenarios nicely by it being a set and having scores.
Achievements
283 Karma
16,218 Total ProTip Views

24PullRequests Continuous Syncs
Sent at least 24 pull requests during the first 24 days of December 2014

24PullRequests Participant
Sent at least one pull request during the first 24 days of December 2014

Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos

Raven
Have at least one original repo where some form of shell script is the dominant language

Kona
Have at least one original repo where CoffeeScript is the dominant language

Forked
Have a project valued enough to be forked by someone else

Mongoose 3
Have at least three original repos where Ruby is the dominant language

Charity
Fork and commit to someone's open source project in need

Mongoose
Have at least one original repo where Ruby is the dominant language
I'd recommend this form:
This even handles scenarios when
some_expensive_operation
validly returnsnil