Home > Backend Development > Python Tutorial > Manage scheduled tasks through reidis

Manage scheduled tasks through reidis

巴扎黑
Release: 2016-12-03 10:14:50
Original
1796 people have browsed it

The main application scenarios are: one-time scheduled tasks with changing requirements.
Execute corresponding commands by monitoring redis expiration events. (Note: Because monitoring can only get the key, you need to store the specific execution content separately)
Also remember to modify the redis configuration: 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
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template