以编程方式销毁/删除 Redis 队列 (rq) 中的 Queue() [英] Destroying / removing a Queue() in Redis Queue (rq) programmatically
本文介绍了以编程方式销毁/删除 Redis 队列 (rq) 中的 Queue()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定:
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'
推荐答案
尝试以下操作(您可以使用 redis-cli 验证所有这些):
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.
这篇关于以编程方式销毁/删除 Redis 队列 (rq) 中的 Queue()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文