Home > Database > Redis > body text

Redis implements order cancellation if not paid within 30 minutes

Release: 2020-06-02 09:03:51
forward
3460 people have browsed it

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!

Related labels:
source:segmentfault.com
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