Home  >  Article  >  Database  >  Redis implements order cancellation if not paid within 30 minutes

Redis implements order cancellation if not paid within 30 minutes

尚
forward
2020-06-02 09:03:513360browse

Redis implements order cancellation if not paid within 30 minutes

Application background

  1. If the order is not paid within 30 minutes after the order is placed, the order will be canceled

  2. No one responds to the timeout request for rent and purchase, the deposit will be returned

  3. Various businesses that can be implemented using timeout

Application principle

  • Redis setex sets a key for a specified time, setex order_no 1800 1

  • Open psubscribe Listen for key expiration events. Note that setex psubscribe needs to be in the same Redis db

Business implementation

  • Processed according to the key in the callback Business ~ Feel free here

Linux configuration

  • ##Set daemon nohup php psubscribe.php &

  • Close the process ps aux | grep "nohup php psubscribe.php &" Find the pid and then kill

  • Set up automatic startup

Code address: https://github.com/SmallForest/redisKeyCancel

For more redis knowledge, please pay attention to the

redis introductory tutorial column.

The above is the detailed content of Redis implements order cancellation if not paid within 30 minutes. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete