好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

通过reidis管理定时任务

主要应用场景为:有变动需求的一次性定时任务。
通过redis过期事件的监听,执行相应命令。(注意:因为监听只能得到key, 所以需要另外存储具体执行内容体)
另外记得修改redis配置:notify-keyspace-events Ex

import redis  
rdc = redis.StrictRedis()               
pubsub = rdc.pubsub()  
pubsub.psubscribe("__keyevent@0__:expired")  
while pubsub.subscribed:  
    msg = pubsub.get_message()  
    if msg:  
        print msg 

查看更多关于通过reidis管理定时任务的详细内容...

  阅读:40次