Destroying / removing a Queue() in Redis Queue (rq) programmatically

安稳与你 提交于 2019-12-11 09:59:32

问题


Given:

from redis import Redis
from rq import Queue

yesterday = Queue('yesterday', connection=Redis())
today = Queue('today', connection=Redis())

I would like to programmatically delete the Queue named 'yesterday'


回答1:


Try the following (you can validate all of this with redis-cli):

yesterday.empty()  # This will wipe out rq:queue:yesterday and all of its contents
del(yesterday)  # Deletes the variable itself
r = Redis()
r.srem('rq:queues', 'rq:queue:yesterday')  # Removed the entry from rq:queues set. The library unfortunately doesn't seem to clean this up by itself.


来源:https://stackoverflow.com/questions/25129509/destroying-removing-a-queue-in-redis-queue-rq-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!