Inventory deduction control methods, devices, electronic devices and media
By asynchronously processing inventory deduction information in a cache database and using Redis for fast caching of inventory deductions, combined with message queues and a queue list, the problem of inventory database crashes under high concurrency was solved, improving the efficiency of inventory management and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HAIER YOUJIA INTELLIGENT TECH (BEIJING) CO LTD
- Filing Date
- 2022-11-29
- Publication Date
- 2026-05-26
AI Technical Summary
The existing inventory management module experiences reduced inventory database performance under high concurrency, which may even lead to database crashes in severe cases.
In response to pre-occupancy requests, the cache inventory in the cache database is deducted and the deduction information is stored in the inventory database pre-occupancy queue list. Combined with the message queue, the actual inventory in the inventory database is deducted accordingly. A remote dictionary service database such as Redis is used for fast deduction of cache inventory, and cache inventory information is processed asynchronously under high concurrency.
It effectively reduced the query pressure on the inventory database, increased the speed of inventory deduction, prevented overselling, and improved the user experience.
Smart Images

Figure CN115729969B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart home / intelligent home technology, specifically providing an inventory deduction control method, device, electronic device, and medium. Background Technology
[0002] In routine inventory management, inventory deductions often rely on an inventory database, such as a MySQL database. This approach uses optimistic locking to ensure consistency during deductions. While this method may not cause issues in low-concurrency environments, it often leads to high concurrency during promotions or flash sales. For example, if a user buys only one item and the inventory check passes, another concurrent request might enter during the actual deduction process. This can result in a phantom read of the inventory database, causing the deduction to fail. This leads to multiple database queries, which, in high-concurrency environments, significantly increases the probability of these queries, directly degrading the database's performance and potentially causing it to crash.
[0003] Accordingly, a new inventory deduction control method is needed in this field to address the above problems. Summary of the Invention
[0004] The present invention aims to solve the above-mentioned technical problems, namely, to solve the problem that the performance of the inventory database will be reduced under high concurrency of the existing inventory management module, and in severe cases, the inventory database may even crash.
[0005] To achieve the above objectives, in a first aspect, the present invention provides an inventory deduction control method, the method comprising the following steps:
[0006] In response to a pre-occupancy request, the cache inventory in the cache database is deducted and the deduction information is stored in the inventory database pre-occupancy queue list;
[0007] Based on the inventory database queue list and message queue, the actual inventory in the inventory database is deducted accordingly, wherein the message queue stores the deduction information during the transmission of the deduction information.
[0008] In the optional technical solutions of the above inventory deduction control method, the step of deducting cached inventory from the cache database and storing the deduction information in the inventory database queue list includes:
[0009] Based on the asynchronous approach, the cache inventory in the cache database is deducted, and the deduction information is stored in the inventory database queue list.
[0010] In the optional technical solutions of the above inventory deduction control method, the cache database is a remote dictionary service database, and the step of deducting the cache inventory in the cache database in response to the pre-occupancy request includes:
[0011] Determine whether the pre-booking request is a valid request;
[0012] Once the pre-reservation request is determined to be a valid request, the cache inventory in the remote dictionary service database is deducted.
[0013] In the optional technical solutions of the above inventory deduction control method, determining whether the pre-occupancy request is a valid request includes:
[0014] Determine whether the cache inventory in the remote dictionary service database is greater than or equal to the pre-reservation quantity in the pre-reservation request;
[0015] When the cache inventory in the remote dictionary service database is greater than or equal to the pre-reserved quantity, the pre-reserved request is determined to be a valid request; otherwise, the pre-reserved request is determined to be an invalid request.
[0016] In the optional technical solutions of the above inventory deduction control method, before deducting the actual inventory in the inventory database based on the inventory database queue list and message queue, the method further includes:
[0017] Query whether the inventory database's inventory queue list contains unprocessed deduction information from the inventory database;
[0018] When the inventory database contains unprocessed deduction information, the actual inventory in the inventory database is deducted accordingly.
[0019] In the optional technical solutions of the above inventory deduction control method, the step of deducting the actual inventory in the inventory database accordingly when the inventory database contains unprocessed deduction information includes:
[0020] Push the unprocessed deduction information of the inventory database in the inventory database queue list to the message queue;
[0021] After pushing the unprocessed deduction information of the inventory database in the inventory queue list to the message queue, the actual inventory in the inventory database is deducted accordingly based on the message queue.
[0022] In the optional technical solutions of the above inventory deduction control method, before deducting the actual inventory in the inventory database based on the message queue, the method further includes:
[0023] Data verification is performed on the unprocessed deduction information in the inventory database in the inventory database queue list contained in the message queue;
[0024] Once the data verification is successful, the actual inventory in the inventory database will be reduced accordingly.
[0025] In a second aspect, the present invention also provides an inventory deduction control device, the device comprising:
[0026] The response module is configured to deduct cache inventory from the cache database and store the deduction information in the inventory database reservation queue list in response to a reservation request, wherein the reservation request is initiated by the user.
[0027] The deduction module is configured to deduct the actual inventory in the inventory database based on the inventory queue list and message queue, wherein the message queue stores the deduction information during the transmission of the deduction information.
[0028] In a third aspect, the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the inventory deduction control method as described in any one of the preceding descriptions.
[0029] In a fourth aspect, the present invention also provides a readable storage medium storing a plurality of program codes adapted to be loaded and run by a processor to perform the inventory deduction control method described in any one of the preceding descriptions.
[0030] Those skilled in the art will understand that, in the technical solution of this invention, in response to a pre-occupancy request, the cached inventory in the cache database is deducted and the deduction information is stored in the inventory database's pre-occupancy queue list, wherein the pre-occupancy request is initiated by the user client; based on the inventory database's pre-occupancy queue list and the message queue, the actual inventory in the inventory database is deducted accordingly, wherein the message queue stores the deduction information during the transmission of the deduction information. This setup can reduce queries to the inventory database, alleviate the pressure on the inventory database, and at the same time, the use of the message queue can effectively realize the deduction of inventory in the inventory database, thereby effectively coping with high concurrency.
[0031] Furthermore, the cache database is a remote dictionary service database. In response to a pre-emption request, deducting cache inventory from the cache database involves: determining whether the pre-emption request is valid; and, if valid, deducting the cache inventory from the remote dictionary service database. This setup, based on a single thread using the remote dictionary service database, increases confidence in the correctness of the data returned after deducting cache inventory from the remote dictionary service database. Simultaneously, determining whether a pre-emption request is valid effectively prevents overselling, further enhancing the user experience. Attached Figure Description
[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 This is a schematic diagram of the hardware environment for an interaction method of a smart device according to an embodiment of the present invention;
[0035] Figure 2 This is a flowchart of the main steps of the inventory deduction control method according to an embodiment of the present invention;
[0036] Figure 3 This is a flowchart of the main steps for determining whether a pre-occupancy request is a valid request according to an embodiment of the present invention;
[0037] Figure 4 This is a flowchart of the main steps for deducting the actual inventory from the inventory database according to an embodiment of the present invention.
[0038] Figure 5 This is a main structural block diagram of the inventory deduction control device according to an embodiment of the invention;
[0039] Figure 6 This is a main structural block diagram of an electronic device used to execute the inventory deduction control method of the present invention. Detailed Implementation
[0040] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0042] In the description of this application, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, a microprocessor, a digital signal processor, or any other suitable processor. A processor has data and / or signal processing capabilities. A processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The singular terms "an" and "this" can also include plural forms.
[0043] According to one aspect of the embodiments of this application, an inventory deduction control method is provided. This inventory deduction control method is widely used in whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned inventory deduction control method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0044] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, etc.
[0045] As described in the background section, e-commerce systems have inventory management modules. How to solve the overselling problem during normal sales is a challenge for developers. While existing development processes offer various solutions, they all have certain shortcomings. For example, using optimistic locking in the database to ensure consistency of deductions involves assuming that no one else will modify the data simultaneously. Optimistic locking assumes that no one else will modify the data at the same time, so it doesn't lock by default. It only checks whether someone else has modified the data during the update process; if so, the operation is abandoned; otherwise, it proceeds. This approach is logically simple and has low development and deployment costs, but under high concurrency, the overall system performance drops sharply, potentially even causing database crashes. Therefore, this invention provides an inventory deduction control method.
[0046] See appendix Figure 2 , Figure 2 This is a flowchart illustrating the main steps of the inventory deduction control method according to an embodiment of the present invention. Figure 2 As shown, the inventory deduction control method of the present invention includes the following steps:
[0047] Step S201: In response to the pre-occupancy request, deduct the cache inventory in the cache database and store the deduction information in the inventory database pre-occupancy queue list, wherein the pre-occupancy request is initiated by the user.
[0048] For example, the deduction information for cached inventory in the cache database includes at least the deducted product information and the deducted quantity information. The above-described settings for deduction information are merely illustrative and can be selected according to actual needs in practical applications.
[0049] In some embodiments, deducting cached inventory from the cache database and storing the deduction information in the inventory database's queue list includes: deducting cached inventory from the cache database and storing the deduction information in the inventory database's queue list based on an asynchronous approach. Specifically, the asynchronous approach means that instead of waiting indefinitely to complete the current process, subsequent processes continue to execute, and the current process is notified to process information when it is returned. In this embodiment, the asynchronous approach means that instead of waiting for the cached inventory deduction in the cache database to be completed before storing the deduction information in the cache database's queue list, the deduction information can be stored in the inventory database's queue list during the process of deducting the cached inventory from the cache database. This setting can improve the speed of deducting the actual inventory from the inventory database under high concurrency, thereby further improving the user experience.
[0050] In some embodiments, before storing the deduction information of cached inventory in the cache database into the inventory database queue list, the method further includes: performing a write-in verification on the inventory database; and after passing the write-in verification, storing the deduction information of cached inventory in the cache database into the inventory database queue list. Exemplarily, the write-in verification includes at least verifying the actual inventory in the inventory database and verifying whether the inventory database queue list already contains the deduction information of the cached inventory to be written. Verifying whether the inventory database queue list already contains the deduction information of the cached inventory to be written can prevent duplicate data writes. The above-described write-in verification settings are merely illustrative and can be configured according to actual needs in practical applications.
[0051] Step S202: Based on the inventory database queue list and message queue, deduct the actual inventory in the inventory database accordingly. The message queue stores the deduction information during the transmission of the deduction information.
[0052] Based on the above steps S201 and S202, this invention, in response to a pre-occupancy request, deducts cached inventory from the cache database and stores the deduction information in the inventory database's occupancy queue list, wherein the pre-occupancy request is initiated by the user client; based on the inventory database's occupancy queue list and the message queue, the actual inventory in the inventory database is deducted accordingly, wherein the message queue stores the deduction information during transmission. This setup reduces queries to the inventory database, alleviating the pressure on the inventory database, while the use of the message queue effectively deducts the actual inventory from the inventory database, thus effectively handling high concurrency.
[0053] In some embodiments, the cache database is a remote dictionary service database. Responding to a pre-emption request, deducting cache inventory from the cache database includes: determining whether the pre-emption request is valid; and, if the pre-emption request is valid, deducting the inventory from the remote dictionary service database. Specifically, compared to relational databases such as MySQL, which primarily store persistent data on disk, resulting in relatively slow read speeds, the remote dictionary service (RemoteDictionaryServer, i.e., Redis) database is a NoSQL database, i.e., a non-relational database, which stores data in memory, resulting in fast cache read speeds and significantly improved operational efficiency. Thus, in high-concurrency situations, front-end users can deduct and query from the Redis database instead of directly accessing the inventory database, greatly reducing queries to the inventory database; furthermore, Redis is single-threaded, ensuring the reliability of the data returned by Redis.
[0054] In some embodiments, after determining that the pre-reservation request is valid, before deducting the inventory in the Redis database, the method further includes: enabling a transaction lock on the Redis database. Specifically, a transaction is an indivisible sequence of database operations and the basic unit of database concurrency control. Its execution result must cause the database to transition from one consistent state to another; that is, a transaction is a logically grouped set of operations that either all are executed or none are executed. In this embodiment, enabling a transaction lock on the Redis database before deducting the inventory ensures that the cache inventory deduction operation in the Redis database is executed sequentially and is not interrupted by other instructions sent by the front-end user, thus guaranteeing the integrity of the cache inventory deduction operation in the Redis database.
[0055] See appendix Figure 3 , Figure 3 This is a flowchart illustrating the main steps of determining whether a pre-booking request is a valid request, according to an embodiment of the present invention. Figure 3 As shown, in some embodiments, determining whether a pre-emption request is a valid request includes the following steps:
[0056] Step S301: Determine whether the cache inventory in the Redis database is greater than or equal to the pre-reservation quantity in the pre-reservation request.
[0057] Step S302: When the cache inventory in the Redis database is greater than or equal to the pre-reserved quantity, the pre-reserved request is determined to be a valid request; otherwise, the pre-reserved request is determined to be an invalid request.
[0058] For example, the cache inventory in the Redis database can be 100, and the pre-emption quantity in the user's pre-emption request can be 10. In this case, if the cache inventory in the Redis database is greater than or equal to the pre-emption quantity in the pre-emption request, the pre-emption request is considered valid. Alternatively, the cache inventory in the Redis database can be 100, and the pre-emption quantity in the user's pre-emption request can be 200. In this case, if the cache inventory in the Redis database is less than the pre-emption quantity in the pre-emption request, the pre-emption request is considered invalid. The values of the cache inventory in the Redis database and the pre-emption quantity in the pre-emption request described above are only illustrative examples. In practical applications, the appropriate values can be selected based on actual needs.
[0059] In some embodiments, before deducting the actual inventory in the inventory database based on the inventory database queue list and message queue, the method further includes: querying whether the inventory database queue list contains unprocessed deduction information; and when unprocessed deduction information is found, deducting the actual inventory in the inventory database accordingly. Specifically, the inventory deduction information stored in the inventory database queue list indicates that the cache database has already deducted or is in the process of deducting the corresponding cached inventory. When the inventory database queue list contains unprocessed deduction information, it indicates that although the cache database has already deducted or is in the process of deducting the corresponding cached inventory, the inventory database has not yet deducted the corresponding actual inventory, thus causing a separation between the cache database and the inventory database. Therefore, to ensure consistency between the cache database and the inventory database, the actual inventory in the inventory database needs to be deducted accordingly when the inventory database queue list contains unprocessed deduction information.
[0060] See appendix Figure 4 , Figure 4 This is a flowchart illustrating the main steps of deducting actual inventory from the inventory database according to an embodiment of the present invention. Figure 4 As shown, in some embodiments, when unprocessed deduction information is included in the inventory database, deducting the actual inventory in the inventory database accordingly includes:
[0061] Step S401: Push the unprocessed deduction information of the inventory database in the inventory database queue list to the message queue.
[0062] Step S402: After pushing the unprocessed deduction information of the inventory database in the inventory queue list to the message queue, deduct the corresponding amount from the actual inventory in the inventory database based on the message queue.
[0063] Specifically, a message queue (MQ) is a container that stores messages during transmission and is primarily used for communication between distributed systems. In message queue applications, the party sending the message queue is the producer, and the party receiving the message queue is the consumer. Deducting actual inventory from the inventory database based on a message queue involves: performing business logic processing in the inventory database, querying the corresponding storage location, deducting the actual inventory of the corresponding SKU, and recording the inventory flow. Here, SKU stands for Product Unique Number, and each product has a unique SKU number.
[0064] In some embodiments, before deducting the actual inventory in the inventory database based on the message queue, the method further includes: performing data verification on the unprocessed deduction information in the inventory database queue list contained in the message queue; and deducting the actual inventory in the inventory database accordingly after the data verification passes. Specifically, performing data verification on the unprocessed deduction information in the inventory database queue contained in the message queue includes: determining whether the unprocessed deduction information in the inventory database queue contained in the message queue contains abnormal data; if abnormal data is found, it is sent to the relevant operations and maintenance personnel via SMS and / or email; otherwise, the data verification passes.
[0065] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0066] See appendix Figure 5 , Figure 5 This is a main structural block diagram of an inventory deduction control device according to an embodiment of the invention.
[0067] like Figure 5 As shown, the present invention also provides an inventory deduction control device, the device comprising:
[0068] Response module 501 is configured to deduct cache inventory from the cache database and store the deduction information in the inventory database reservation list in response to a reservation request, wherein the reservation request is initiated by the user.
[0069] The deduction module 502 is configured to deduct the actual inventory in the inventory database based on the inventory queue list and message queue. The message queue stores the deduction information during the transmission of the deduction information.
[0070] In some embodiments, the response module 501 deducts cache inventory from the cache database based on the asynchronous principle and stores the deduction information in the inventory database queue list.
[0071] In some embodiments, the cache database is a Redis database, and the response module 501 determines whether the pre-emption request is a valid request; if the pre-emption request is determined to be a valid request, the inventory in the Redis database is deducted.
[0072] In some embodiments, the response module 501 determines whether the cache inventory in the Redis database is greater than or equal to the pre-reservation quantity in the pre-reservation request; if the cache inventory in the Redis database is greater than or equal to the pre-reservation quantity, the pre-reservation request is determined to be a valid request; otherwise, the pre-reservation request is determined to be an invalid request.
[0073] In some embodiments, the deduction module 502 queries the inventory database inventory queue list to see if it contains unprocessed deduction information from the inventory database; when it contains unprocessed deduction information from the inventory database, it deducts the corresponding amount from the actual inventory in the inventory database.
[0074] In some embodiments, the deduction module 502 pushes unprocessed deduction information from the inventory database in the inventory database queue list to the message queue; after completing the push of unprocessed deduction information from the inventory database in the inventory database queue list to the message queue, it deducts the actual inventory in the inventory database accordingly based on the message queue.
[0075] In some embodiments, the deduction module 502 performs data verification on the unprocessed deduction information in the inventory database in the inventory database queue list contained in the message queue; when the data verification passes, the actual inventory in the inventory database is deducted accordingly.
[0076] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0077] See appendix Figure 6 , Figure 6 This is a main structural block diagram of an electronic device used to execute the inventory deduction control method of embodiments of the present invention. (See diagram below.) Figure 6As shown, the present invention also provides an electronic device for executing the inventory deduction control method of the embodiments of the present invention. The electronic device 600 includes a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program 603, it implements the steps in the various method embodiments described above. Alternatively, when the processor 601 executes the computer program 603, it implements the functions of each module / unit in the device embodiments described above.
[0078] For example, processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0079] For example, memory 602 can be an internal storage unit of electronic device 600, such as a hard disk or memory of electronic device 600; memory 602 can also be an external storage device of electronic device 600, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on electronic device 600. Furthermore, memory 602 can include both internal storage units and external storage devices of electronic device 600. Memory 602 is used to store computer programs and other programs and data required by electronic device 600, and memory 602 can also be used to temporarily store data that has been output or will be output.
[0080] Exemplarily, computer program 603 may be divided into one or more modules / units, which are stored in memory 602 and executed by processor 601 to perform the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 603 in electronic device 600.
[0081] Electronic device 600 may be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 600 may include, but is not limited to, processor 601 and memory 602. Those skilled in the art will understand that... Figure 6 This is merely an example of electronic device 600 and does not constitute a limitation on electronic device 600. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.
[0082] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0083] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments of the invention herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the invention.
[0084] In the embodiments provided by this invention, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the electronic device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0085] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0086] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0087] If integrated modules / units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in a computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0088] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. An inventory deduction control method, characterized in that, The method includes the following steps: In response to a pre-occupancy request, the cache inventory in the cache database is deducted and the deduction information is stored in the inventory database pre-occupancy queue list, wherein the pre-occupancy request is initiated by the user client; Query whether the inventory database's inventory queue list contains unprocessed deduction information from the inventory database; When the inventory database contains unprocessed deduction information, the actual inventory in the inventory database is deducted accordingly. Push the unprocessed deduction information from the inventory database in the inventory database queue to the message queue. After pushing the unprocessed deduction information of the inventory database in the inventory queue list to the message queue, the actual inventory in the inventory database is deducted accordingly based on the message queue. The message queue stores the deduction information during the transmission of the deduction information.
2. The inventory deduction control method according to claim 1, characterized in that, The step of deducting cache inventory from the cache database and storing the deduction information in the inventory database queue list includes: Based on the asynchronous approach, the cache inventory in the cache database is deducted, and the deduction information is stored in the inventory database queue list.
3. The inventory deduction control method according to claim 1, characterized in that, The cache database is a remote dictionary service database, and the process of deducting cache inventory from the cache database in response to the pre-occupancy request includes: Determine whether the pre-booking request is a valid request; Once the pre-reservation request is determined to be a valid request, the cache inventory in the remote dictionary service database is deducted.
4. The inventory deduction control method according to claim 3, characterized in that, The determination of whether the pre-booking request is a valid request includes: Determine whether the cache inventory in the remote dictionary service database is greater than or equal to the pre-reservation quantity in the pre-reservation request; When the cache inventory in the remote dictionary service database is greater than or equal to the pre-reserved quantity, the pre-reserved request is determined to be a valid request; otherwise, the pre-reserved request is determined to be an invalid request.
5. The inventory deduction control method according to claim 1, characterized in that, Before deducting the actual inventory in the inventory database based on the message queue, the method further includes: Data verification is performed on the unprocessed deduction information in the inventory database in the inventory database queue list contained in the message queue; Once the data verification is successful, the actual inventory in the inventory database will be reduced accordingly.
6. An inventory deduction control device, characterized in that, The device includes: The response module is configured to deduct cache inventory from the cache database and store the deduction information in the inventory database reservation queue list in response to a reservation request, wherein the reservation request is initiated by the user. The deduction module is configured to deduct the actual inventory in the inventory database based on the inventory queue list and message queue, wherein the message queue stores the deduction information during the transmission of the deduction information; The deduction module is further configured to query whether the inventory database queue list contains unprocessed deduction information from the inventory database; when unprocessed deduction information from the inventory database is included, the actual inventory in the inventory database is deducted accordingly, and the unprocessed deduction information from the inventory database queue list is pushed to a message queue; after pushing the unprocessed deduction information from the inventory database queue list to the message queue, the actual inventory in the inventory database is deducted accordingly based on the message queue.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the inventory deduction control method as described in any one of claims 1 to 5.
8. A readable storage medium storing a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by a processor to perform the inventory deduction control method as described in any one of claims 1 to 5.