在Redis队列(rq)中程序化销毁/移除队列()
给定:
from redis import Redis
from rq import Queue
yesterday = Queue('yesterday', connection=Redis())
today = Queue('today', connection=Redis())
我想通过编程的方式删除一个叫做'yesterday'的队列。
1 个回答
4
试试下面这个方法(你可以用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.