The main application scenarios are: one-time scheduled tasks with changing requirements. Use the redis expiration event monitoring to execute the corresponding command. (Note: Because the listener can only get the key, so you need to store the specific execution content body) also remember to modify the redis configuration: notify-keyspace-eventsEximportredisrdcredis.StrictRedis () pubsubrdc. pubsub () pub... the main application scenarios are: one-time scheduled tasks with changing requirements.
Use the redis expiration event monitoring to execute the corresponding command. (Note: Because the listener can only get the key, you need to store the specific execution content body)
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