GithubHelp home page GithubHelp logo

dqueue's Introduction

dqueue

dqueue is a distributed queue wrapper for redis-py package.

dqueue implements scenario of multiple users working simultaneously with a pool of projects represented by ids. Each user can lock a bunch of projects exclusively so that no other users can lock the same ids for themselves until the lock is expired.

A real-world problem the dqueue solves is work of adminstrators/moderators team processing projects: pushing them into queue, locking, removing projects from the queue, etc, so that each team member could work with his or her own portion from the pool of all projects.

Example

$ docker run -p 6379:6379 redis
$ python

>>> import redis, dqueue
>>> connection = redis.StrictRedis(host='localhost', port=6379, db=0)
>>> queue = dqueue.DistributedQueue(connection=connection, ttl_seconds=60*20)
>>> queue.lock_pids(user_id=1, pids=[1,2,3,4,5])
{1, 2, 3, 4, 5}
>>> queue.lock_pids(user_id=2, pids=[6,7,8])
{6, 7, 8}
>>> queue.retrieve_user(user_id=1)
{1, 2, 3, 4, 5}
>>> queue.retrieve_user(user_id=2)
{6, 7, 8}
>>> queue.retrieve_all()
{1, 2, 3, 4, 5, 6, 7, 8}
>>> queue.remove_pids(user_id=2, pids=[6,8])
{6, 8}
>>> queue.remove_all(user_id=1)
{1, 2, 3, 4, 5}
>>> queue.retrieve_all()
{7}

Author

dqueue developed and maintained by Vitaly R. Samigullin.

License

See LICENSE file.

dqueue's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.