concurrency - Concurrent priority queue in redis? -



concurrency - Concurrent priority queue in redis? -

i implement concurrent priority queue in redis, multiple processes on different machines adding items (with scores) , multiple other processes popping these items, lowest score first.

a simple queue can implemented lpush , rpop.

using zset, can add together items using zadd , pop them zrange , zrem, long there 1 reader.

for multiple readers think need zpop combines zrange , zrem in single atomic operation. otherwise 2 readers may same item zrange before either can zrem it. retrying if zrem returns 0 work not desirable.

is there way can using current redis commands? there reason hasn't been added redis already? seems pretty simple command implement.

you can guarantee atomicity if utilize lua script zrange & zrem or multi/exec block. prevent multiple workers interfering each other.

i assume zpop wasn't set in in first place because isn't mutual utilize case and, when needed, can scripted.

concurrency redis priority-queue

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -