以编程方式在Redis队列(rq)中销毁/删除队列()

时间:2014-08-05 00:25:08

标签: python redis python-rq

假设:

from redis import Redis
from rq import Queue

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

我想以编程方式删除名为'昨天'

的队列

1 个答案:

答案 0 :(得分:3)

尝试以下方法(您可以使用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.