search

Home  >  Q&A  >  body text

How to use redis to cancel an order in 15 minutes in thinkphp5?

1. I want to use the queue to detect whether the order has been placed for more than 15 minutes. If it exceeds 15 minutes, modify the database to timeout cancellation, but I don’t know how to start.

过去多啦不再A梦过去多啦不再A梦2752 days ago1699

reply all(5)I'll reply

  • 漂亮男人

    漂亮男人2017-06-06 09:54:43

    This function can be made to trigger user behavior. For example, when the user checks the order and determines that it has not been paid and it has exceeded 15 minutes, the order status will be changed to timeout cancellation. Orders that have not been viewed and whose status has not been updated may be updated in the early morning by scheduled tasks. When the order volume is large, it is not recommended to synchronize the status of all orders in real time, and it is meaningless.

    reply
    0
  • 怪我咯

    怪我咯2017-06-06 09:54:43

    Database polling: Use scheduled tasks to poll the database and query related order processing. Use it when the volume is not large. This method is simple, practical and easy to maintain in small projects

    Ring Queue: Reference: http://mp.weixin.qq.com/s/mvF...

    Queue service: Use delayed queue processing Reference: http://tech.youzan.com/queuin...

    reply
    0
  • 高洛峰

    高洛峰2017-06-06 09:54:43

    A better solution is to use a time wheel, which is the ring queue mentioned above.
    It can also be achieved using Redis key space notification. Set the expiration time to 15 minutes, listen for key deletion events, and perform corresponding operations

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-06 09:54:43

    Isn’t it good to use a timer?

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-06 09:54:43

    No need for redis

    You can do it with MySQL

    Plan:
    Write a PHP script, execute the daemon process,
    while loop, check the library, if the order takes more than 15 minutes, and the order is unpaid and unshipped, the cancellation operation will be performed

    reply
    0
  • Cancelreply