gpt4 book ai didi

python - 以编程方式销毁/删除 Redis 队列 (rq) 中的 Queue()

转载 作者:IT王子 更新时间:2023-10-29 06:10:06 27 4
gpt4 key购买 nike

给定:

from redis import Redis
from rq import Queue

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

我想以编程方式删除名为“昨天”的队列

最佳答案

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

关于python - 以编程方式销毁/删除 Redis 队列 (rq) 中的 Queue(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25129509/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com