In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Python how to achieve automatic cancellation of order timeout, for this problem, this article details the corresponding analysis and answer, hoping to help more small partners who want to solve this problem to find a simpler and easier way.
Business scenario: After the user places an order, if the payment is not completed within the specified time, the order is automatically cancelled and the inventory is released. Technology: Redis key space notification (expiration callback) After the user places an order, the order id is stored as a key and any value is stored as a value in redis. The expiration time is set for this data, that is, the time when the order expires. Enable key space notification.
Keyspace event notification is disabled by default. We can enable them in redis.conf or redis-cli (windows in redis.window-server.conf) as follows:
Or use the command line settings:
redis-cli config set notify-keyspace-events Ex
Parameter Description:
Here we only monitor expiration events, so Ex is set
Test effect:
$ redis-cli --csv psubscribe '*'
Reading messages... (press Ctrl-C to quit)
"psubscribe","*",1
psubscribe '*' means we want to subscribe to all events using schema *
Open a new terminal connection redis
Application in Python
The callback function can cancel the order and restore the inventory only by getting the expired order_id
About Python how to achieve automatic cancellation of orders timeout answer to share here, I hope the above content can have some help for everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.