Improvement method of Redis distributed lock based on Mysql database
A distributed lock and database technology, applied in database update, database distribution/replication, electronic digital data processing, etc.
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0020] The order modification operation prevents multiple threads from modifying the order at the same time:
[0021] s11. A user is modifying an order. Before modifying the information of order A, the corresponding thread 1 uses the SetNX command of Redis to set the value and expiration time for the business key of order A. If the setting fails, it means that thread 1 has not After acquiring the lock, thread 1 terminates the operation; if the setting is successful, thread 1 enters s12;
[0022] S12. Thread 1 updates the status of order A in the Mysql database order table to "operating". If the update result returns 1, it means that there is no thread performing operations related to order A at this time, that is, there is no concurrency, and enters s13 ; If the update result returns 0, it means that other threads are performing operations related to order A at this time, and thread 1 terminates the operation;
[0023] S13. Thread 1 executes the update operation of order A; r...
Embodiment 2
[0025] Flash kill activities to prevent oversold scenarios
[0026] S21. A user is conducting a flash sale of product A. Before snapping up, the corresponding thread 1 checks whether the inventory of product A is greater than zero. If it is less than zero, thread 1 terminates the operation; if it is greater than zero, then enters S22;
[0027] S22. Thread 1 uses the SetNX command of Redis to set the value and expiration time for the business key corresponding to commodity A in the inventory table. If the setting fails, it means that thread 1 has not acquired the lock, and thread 1 terminates the operation; if the setting is successful, thread 1 enter s23;
[0028] S23. Thread 1 updates the status of commodity A in the inventory table of the Mysql database to "operating". If the update result returns 1, it means that there is no thread performing operations related to commodity A inventory at this time, that is, there is no concurrency, enter s4; if the update result returns 0...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com