Redis FIFO queue

201 views
Skip to first unread message

Marius M.

unread,
Jan 27, 2014, 6:16:08 AM1/27/14
to redi...@googlegroups.com
Hi,

I'm thinking to use redis as a First In First Out queue, using a list and the LPUSH, RPOP commands.

The queue's consumers will be numerous and asynchronous, so my question would be in order to avoid two consumers RPOP-ing the same key, should I be using BRPOP instead?

Thanks!

Jan-Erik Rediger

unread,
Jan 27, 2014, 6:28:39 AM1/27/14
to redi...@googlegroups.com
It's impossible for two consumers to pop the same element. Redis is
single-threaded and responds to requests in the order they come in.
Race-conditions like the one you mentioned can't happen.

Marius M.

unread,
Jan 27, 2014, 10:58:26 AM1/27/14
to redi...@googlegroups.com
Thanks Jan!

Josiah Carlson

unread,
Jan 28, 2014, 8:17:06 PM1/28/14
to redi...@googlegroups.com
If you are using Redis as a queue, you may want to look into the several different queue packages for Redis available in the language you are programming in.

 - Josiah


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages