简体   繁体   English

Redis到期通知和烧瓶

[英]redis expiration notifications and flask

I'm trying to implement a heartbeat mechanism in Flask via redis (since I'm already using it for a bunch of other stuff already). 我正在尝试通过redis在Flask中实现心跳机制(因为我已经将它用于大量其他东西)。

When a GET request is received, my Flask app sets an expirable redis variable A. Multiple GET requests resets the expiration time of A. When A truly expires, I need to modify a whole bunch of other redis variables. 收到GET请求时,我的Flask应用会设置一个可过期的redis变量A。多个GET请求将重置A的过期时间。当A真正过期时,我需要修改一大堆其他redis变量。

Do I need to setup another redis client acting as a SUB running in the background to detect the expirations? 我是否需要设置另一个充当SUB的redis客户端在后台运行以检测到期时间? Is there a way to do this directly in the same Flask webapp client? 有没有办法在同一个Flask webapp客户端中直接执行此操作?

You will need another client in background listening to the key expiration notifications. 您将需要另一个客户端在后台侦听密钥到期通知。 Also note that this feature is only present in Redis 2.8. 另请注意,此功能仅在Redis 2.8中提供。 So if you are using a previous version you will need to handle the notification yourself. 因此,如果您使用的是以前的版本,则需要自己处理通知。 There is a lengthy explanation about the alternatives in this StackOverflow post . 关于这个StackOverflow帖子中的替代方法有很长的解释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM