CN112860746B - Cache reduction-based method, equipment and system - Google Patents

Cache reduction-based method, equipment and system Download PDF

Info

Publication number
CN112860746B
CN112860746B CN202110137445.4A CN202110137445A CN112860746B CN 112860746 B CN112860746 B CN 112860746B CN 202110137445 A CN202110137445 A CN 202110137445A CN 112860746 B CN112860746 B CN 112860746B
Authority
CN
China
Prior art keywords
inventory
cache
stock
verification
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110137445.4A
Other languages
Chinese (zh)
Other versions
CN112860746A (en
Inventor
张义
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Wanwu Xinsheng Environmental Technology Group Co
Original Assignee
Shanghai Wanwu Xinsheng Environmental Technology Group Co
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Wanwu Xinsheng Environmental Technology Group Co filed Critical Shanghai Wanwu Xinsheng Environmental Technology Group Co
Priority to CN202110137445.4A priority Critical patent/CN112860746B/en
Publication of CN112860746A publication Critical patent/CN112860746A/en
Application granted granted Critical
Publication of CN112860746B publication Critical patent/CN112860746B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24539Query rewriting; Transformation using cached or materialised query results
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/08Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
    • G06Q10/087Inventory or stock management, e.g. order filling, procurement or balancing against orders

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Economics (AREA)
  • Computer Security & Cryptography (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Mathematical Physics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Fuzzy Systems (AREA)
  • Human Resources & Organizations (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Strategic Management (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The method, the equipment and the system for reducing the inventory based on the cache are used for disassembling original inventory data based on an inventory reducing request to obtain a plurality of inventories with unique codes; performing first cache verification on the plurality of stocks with the unique codes through distributed cache, and performing second cache verification on the basis of verification results to obtain identification information of stock rows; operating a database based on the identification information of the stock row and sending a current stock change message; and confirming the inventory in the database and carrying out corresponding cache processing by monitoring the current inventory change message. Therefore, the original inventory is disassembled to ensure the minimum granularity of the row lock, the impact of directly operating the database is avoided in a mode of caching the middleware, the database in the inventory is verified and the cache is updated twice in a mode of monitoring inventory change information to ensure the final consistency of the data.

Description

Cache reduction-based method, equipment and system
Technical Field
The present application relates to the field of computers, and in particular, to a method, an apparatus, and a system for cache-based inventory reduction.
Background
The management, reduction, addition and other operations of the commodity inventory data are completely based on the database, when a user requests reduction, the warehouse is directly updated to carry out reduction operation, the commodity data is persisted in the database, the database-based operation is accurate and profiled, but the inventory reduction action directly operates the database, and because the performance of the database is limited, under the condition of high concurrent requests, reduction requests can be overstocked, the requests can fail, database request connection cannot be obtained, and the database cannot provide services to the outside. Will hang up. If the mode of database division and table division is adopted, the performance requirements cannot be met fundamentally, and the reduction situation of high-concurrency scenes cannot be really coped with.
Disclosure of Invention
An object of the present application is to provide a method, an apparatus, and a system for reducing inventory based on cache, which solve the problems in the prior art that in a scenario of high concurrent requests, a database is directly operated, which results in large-area waiting, even paralysis, data in the inventory cache cannot be updated in time, and data is inconsistent.
According to one aspect of the present application, there is provided a method of cache-based inventory cutting, the method comprising:
disassembling original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes;
performing first cache verification on the plurality of stocks with the unique codes through distributed cache, and performing second cache verification on the basis of verification results to obtain identification information of stock rows;
operating a database based on the identification information of the stock row and sending a current stock change message;
and confirming the inventory in the database and carrying out corresponding cache processing by monitoring the current inventory change message.
Optionally, the disassembling of the original inventory data based on the inventory reduction request includes:
the original inventory data is broken into a plurality of rows based on the inventory reduction request, and each row of data indicates an inventory.
Optionally, performing a first cache verification on the plurality of inventories with unique codes through a distributed cache, including:
verifying whether the stocks with the unique codes are left or not through a distributed cache, and if the current stock is in a first state, synchronously returning to the client and simultaneously sending a message to a message notification end to confirm the state of the current stock again;
if the current stock state is the second state again, directly returning to the client, and failing to request for stock reduction;
and if the current inventory is in the third state, performing second cache verification.
Optionally, performing a second cache verification based on the verification result to obtain identification information of the stock row, including:
and when the verification result is that the current stock is in the third state, directly reducing the data of the second cache to obtain the identification information of the stock row, if the identification information is empty, performing the first cache verification again and sending a stock change message notification, and if the identification information is not empty, performing the operation of the database.
Optionally, operating a database based on the identification information of the inventory row and sending a current inventory change message includes:
setting row data corresponding to the identification information of the stock row in the database as reduction or pre-occupation, and if the reduction or pre-occupation fails, sending a current stock change message and carrying out the first cache verification again; and if the reduction or the pre-occupation is successful, returning the operation success to the client.
Optionally, the determining of the inventory in the database and the corresponding caching processing are performed by monitoring the current inventory change message, including:
and judging whether the monitored current inventory change message can be consumed, if so, inquiring the database to confirm whether the current inventory exists, and performing corresponding caching processing according to an inquiry result.
Optionally, performing corresponding caching processing according to the query result, including:
if the query result is that the inventory needs to be added, adding an identification information list of the relevant inventory in the second cache and setting the first cache to be in the third state, and if the inventory does not need to be added, setting the first cache to be in the first state.
According to another aspect of the present application, there is also provided a system for cache-based inventory cutting, the system comprising:
client, stock server, distributed cache, database and management end,
the client is used for sending an inventory reduction request to the inventory server;
the inventory server side is used for disassembling original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes;
the distributed cache is used for carrying out first cache verification on the plurality of stocks with the unique codes and carrying out second cache verification on the basis of verification results to obtain identification information of stock rows;
the database is used for operating based on the identification information of the stock row, and the management end is used for sending a message notice of a current stock change message;
and the inventory server side is used for confirming the inventory in the database and carrying out corresponding cache processing by monitoring the message notification.
According to yet another aspect of the present application, there is also provided an apparatus for cache-based inventory reduction, the apparatus comprising:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method as previously described.
According to yet another aspect of the present application, there is also provided a computer readable medium having computer readable instructions stored thereon, the computer readable instructions being executable by a processor to implement the method as described above.
Compared with the prior art, the method and the system have the advantages that original inventory data are disassembled based on the inventory reduction request, and a plurality of inventories with unique codes are obtained; performing first cache verification on the plurality of stocks with the unique codes through distributed cache, and performing second cache verification on the basis of verification results to obtain identification information of stock rows; operating a database based on the identification information of the stock row and sending a current stock change message; and confirming the inventory in the database and carrying out corresponding cache processing by monitoring the current inventory change message. Therefore, the original inventory is disassembled to ensure the minimum granularity of the row lock, the impact of directly operating the database is avoided in a mode of caching the middleware, the database in the inventory is verified and the cache is updated twice in a mode of monitoring inventory change information to ensure the final consistency of the data.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 illustrates a block diagram of a system for cache-based inventory reduction according to one aspect of the present application;
FIG. 2 illustrates a flow diagram of a method of cache-based inventory reduction according to an aspect of the present application.
The same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the present application, the terminal, the device serving the network, and the trusted party each include one or more processors (e.g., central Processing Units (CPUs)), input/output interfaces, network interfaces, and memory.
The Memory may include volatile Memory in a computer readable medium, random Access Memory (RAM), and/or nonvolatile Memory such as Read Only Memory (ROM) or flash Memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase-Change RAM (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read-Only Memory (EEPROM), flash Memory or other Memory technology, compact Disc Read-Only Memory (CD-ROM), digital Versatile Disc (DVD) or other optical storage, magnetic cassette tape, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
Fig. 1 illustrates a schematic structural diagram of a system for cache-based inventory reduction according to an aspect of the present application, the system comprising: the system comprises a client 11, an inventory server 12, a distributed cache 13, a database 14 and a management terminal 15, wherein the client 11 is used for sending an inventory reduction request to the inventory server 12; the inventory server 12 is configured to disassemble original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes; the distributed cache 13 is used for performing first cache verification on the plurality of stocks with the unique codes and performing second cache verification on the basis of verification results to obtain identification information of stock rows; the database 14 is configured to operate based on the identification information of the stock row, and the management terminal 15 is configured to send a message notification of a current stock change message; the inventory server 12 is configured to perform inventory confirmation and corresponding caching processing in the database 14 by monitoring the message notification. The system mainly comprises a calling end (client), an inventory server, a distributed cache (Redis), a management end (inventory management center), a message notification end (MQ) and a Database (DB), wherein the inventory server splits original inventory data, divides a single line into multiple lines, each line of data indicates an inventory and has a unique code, the specific inventory data is verified through the Redis in a Redis + DB mode, the first cache verifies the state of the inventory, and the second cache obtains specific line identification information (line ID) to perform final DB setting; the management terminal is a management terminal of the stock data, the stock data is required to be processed by the management terminal when being added, deleted, modified and the like, and the implementation mode is that after the service data is changed, the service data is required to be updated into the DB and a changed message MQ notice is sent; the inventory service listens to the MQ messages, performs inventory validation and management of the associated cache, etc. Therefore, when inventory reduction is carried out, direct query and database updating are avoided, database operation is reduced, the condition of data inconsistency is avoided, timely updating of data cached in inventory is guaranteed, and over-selling of commodity inventory is avoided.
FIG. 2 illustrates a flow diagram of a method of cache-based inventory reduction according to an aspect of the present application, the method comprising: step S11 to step S14, wherein,
in step S11, disassembling the original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes; here, the inventory reduction request sent by the client is acquired, and the original inventory data is disassembled based on the inventory reduction request, so that a plurality of inventories are obtained and the codes are unique. Then, in step S12, performing a first cache verification on the plurality of inventories with the unique codes through a distributed cache, and performing a second cache verification based on a verification result to obtain identification information of the inventory row; here, the multiple disassembled stocks are verified by using Redis (distributed cache), the verification is performed twice, the first cache verification verifies the stock state, and the purpose is to confirm whether the stock has an identifier, such as the identifier is present, non-stock-final, so as to perform the second cache verification according to the result of the first cache verification (i.e. the verified stock state), obtain a specific stock row ID, and operate the database to perform actual reduction operation (row operation).
Subsequently, in step S13, operating a database based on the identification information of the stock row and transmitting a current stock change message; here, the database is operated according to the acquired specific stock row ID, the relevant data is set to be reduced or preempted, and the current stock change message corresponding to the ID is transmitted, which is transmitted in an MQ notification form.
Finally, in step S14, the confirmation of the inventory in the database and the corresponding caching process are performed by monitoring the current inventory change message. When the message notification (MQ) of the current inventory change message is monitored, the inventory in the Database (DB) is confirmed and the corresponding caching process is performed, wherein the inventory is confirmed to confirm the status of the inventory, and the corresponding caching process is set for the first caching or the second caching. The MQ notification can also be realized through a watch mechanism of Zookeeper. Therefore, a DB single line is divided into multiple lines, the minimum granularity of a line lock is ensured, the impact of directly operating the DB is avoided in a mode of caching middleware, the stock DB is verified and the cache is updated (twice caching) in a mode of monitoring MQ messages for asynchronous refreshing, and the final consistency of data is ensured.
Optionally, in step S11, the original inventory data is broken down into a plurality of rows based on the inventory reduction request, each row of data indicating an inventory. Splitting original inventory data, namely splitting the original inventory data in the database, splitting a single line into multiple lines, wherein each line of data indicates one inventory, so that multiple inventories are obtained, and each inventory has a unique code; therefore, by utilizing the DB row lock, the minimum granularity of the row lock is ensured, namely, the row lock is changed into a plurality of rows, and the highest performance is updated to the database.
Optionally, in step S12, verifying whether the plurality of inventories with the unique codes remain through the distributed cache, and if the current inventory is in the first state, synchronously returning to the client and simultaneously sending a message to the message notification end to confirm the state of the current inventory again; if the current stock state is the second state again, directly returning to the client, and failing to request for stock reduction; and if the current inventory is in the third state, performing second cache verification. When the stock is reduced, the first cache is verified through Redis, the first cache is of a string type and is used for verifying the stock state, the first state is represented by 0, the mark is out of stock, the second state is represented by-1, the mark confirms that the stock is not available finally, and the third state is represented by 1, and the mark is in stock. Verifying whether the inventory has surplus or not, if so, synchronously returning to the client and simultaneously sending an inventory change message to inform a monitoring end after the use of the current inventory is finished, and finally confirming the state of the inventory; if the number is-1, the final confirmation is no stock, the client side is directly returned, and the request is failed to reduce; if the number is 1, the inventory is remained, and the second cache verification is carried out. Therefore, when the stock state is the middleware state (the first cache is 0), the consistency of the DB and the cache is ensured continuously through a message confirmation mechanism.
As in the above embodiment, when the current inventory is in the third state as a result of the verification, the data in the second cache is directly reduced, the identification information of the inventory row is obtained, if the identification information is empty, the first cache verification is performed again and an inventory change message notification is sent, and if the identification information is not empty, the database operation is performed. Here, when the stock is still left, that is, the stock state is the third state (1), the data of the second cache is directly reduced, the data of the second cache is set type data-span operation, the stock row ID is acquired, if the stock row ID is empty, the first cache verification is performed again, the stock change message notification is transmitted, the number of times of performing the first cache verification again does not exceed the preset number of times, and if the stock row ID is not empty, the database operation is performed. The second time cache is the cache of the inventory row ID, a set structure data set is used, the repeated problem of data can be avoided, meanwhile, a pop mode is adopted, repeated acquisition of the data is avoided, and the side face ensures the granularity influence degree of the row lock. By adopting two times of cache operation, the stock state and the specific stock row ID are known in advance, and the direct impact verification of the database is avoided.
In an embodiment of the present application, in step S13, setting line data corresponding to the identification information of the stock line in the database to be reduction or preemption, and if the reduction or preemption fails, sending a current stock change message and performing the first cache verification again; and if the reduction or the pre-occupation is successful, returning the operation success to the client. And operating the DB, setting related data to reduce or pre-occupy, wherein the related data is row data corresponding to the stock row ID, the process is to improve concurrency by using a row lock, verifying the row stock corresponding to each stock row ID, the current stock is the row stock currently being verified, if the DB operation fails, sending an inventory change message MQ, and meanwhile, carrying out the first verification again, wherein the number of times of the re-execution does not exceed the preset number of times, and if the DB is successfully reduced, returning a notice of successful operation to the client. When the inventory reduction is successful, the mark in the DB can contain a unique value or directly returns an inventory row ID to the client to mark the uniqueness of the reduction; the state of the curtailment may be pre-emption or direct curtailment.
In an embodiment of the present application, in step S14, it is determined whether the monitored current inventory change message can be consumed, if yes, the database is queried to determine whether the current inventory exists, and corresponding caching is performed according to a query result. The management terminal is a management terminal of the inventory data, the addition, deletion, modification and the like of the inventory data need to be processed through the management terminal, and the implementation mode is that after the business data is changed, the business data needs to be updated into the DB and a changed message MQ notice is sent. The inventory change monitoring terminal monitors inventory change Messages (MQ), when the MQ is monitored, whether the MQ can be consumed is confirmed, so that repeated messages are removed, the inventory is prevented from being repeatedly verified, when the MQ can be consumed, the DB is inquired to verify whether the inventory exists, and relevant caching processing is carried out according to the inquiry result.
Specifically, if the query result is that the first cache is not in the second state, setting the first cache to be in the second state, if the query result is that the first cache is in the second state, verifying whether inventory needs to be added, if so, adding an identification information list of relevant inventory in the second cache and setting the first cache to be in the third state, and if not, setting the first cache to be in the first state. If the query result is that the first cache does not exist, setting the state of the first cache to be a second state, namely setting the state to be-1, and identifying to confirm that the stock does not exist finally; when the inventory exists, verifying whether the inventory needs to be added, if so, adding an inventory ID list (set is automatically filtered and repeated) related to the secondary payment and setting the state of the first cache to be a third state, namely setting the state to be 1, and identifying the inventory; if the inventory does not need to be added, setting the state of the first cache to be a first state, namely setting the state to be 0, and identifying that no inventory exists. Therefore, the inventory DB is verified and the cache is updated twice, and the final consistency of the data is ensured. The pressure of the reduction on the DB can be reduced by caching twice, wherein the unique identification list added by the second cache can be added according to a certain speed or a certain rule, namely, the reduction and the current limitation are simultaneously performed.
Furthermore, a computer-readable medium is provided in an embodiment of the present application, and has computer-readable instructions stored thereon, which are executable by a processor to implement the aforementioned method for cache-based inventory reduction.
In an embodiment of the present application, there is further provided an apparatus for cache-based inventory reduction, the apparatus including:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method as previously described.
For example, the computer readable instructions, when executed, cause the one or more processors to:
disassembling original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes;
performing first cache verification on the plurality of stocks with the unique codes through distributed cache, and performing second cache verification on the basis of verification results to obtain identification information of stock rows;
operating a database based on the identification information of the stock row and sending a current stock change message;
and confirming the inventory in the database and carrying out corresponding cache processing by monitoring the current inventory change message.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.

Claims (8)

1. A method for cache-based inventory reduction, the method comprising:
disassembling original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes;
performing first cache verification on the plurality of stocks with the unique codes through distributed cache, and performing second cache verification on the basis of verification results to obtain identification information of stock rows;
operating a database based on the identification information of the stock row and sending a current stock change message;
confirming the inventory in the database and carrying out corresponding cache processing by monitoring the current inventory change message;
performing a first cache verification on the plurality of inventories with the unique codes through the distributed cache, wherein the first cache verification comprises:
verifying whether the stocks with the unique codes are left or not through a distributed cache, and if the current stock is in a first state, synchronously returning to the client and simultaneously sending a message to a message notification end to confirm the state of the current stock again;
if the current stock state is the second state again, directly returning to the client, and failing to request for stock reduction;
if the current stock is in the third state, performing second cache verification;
performing second cache verification based on the verification result to obtain identification information of the stock row, including:
and when the verification result is that the current stock is in the third state, directly reducing the data of the second cache to obtain the identification information of the stock row, if the identification information is empty, performing the first cache verification again and sending a stock change message notification, and if the identification information is not empty, performing the operation of the database.
2. The method of claim 1, wherein the disassembling of the raw inventory data based on the inventory curtailment request comprises:
the original inventory data is broken into a plurality of rows based on the inventory reduction request, and each row of data indicates an inventory.
3. The method of claim 1 or 2, wherein operating a database based on the identification information of the inventory row and sending a current inventory change message comprises:
setting row data corresponding to the identification information of the stock row in the database as reduction or pre-occupation, and if the reduction or pre-occupation fails, sending a current stock change message and carrying out the first cache verification again; and if the reduction or the pre-occupation is successful, returning the operation success to the client.
4. The method according to claim 1, wherein the confirming of the inventory in the database and the corresponding caching process by monitoring the current inventory change message comprises:
and judging whether the monitored current inventory change message can be consumed or not, if so, inquiring the database to confirm whether the current inventory exists or not, and performing corresponding caching processing according to an inquiry result.
5. The method of claim 4, wherein performing corresponding caching processing according to the query result comprises:
if the query result is that the first cache is not in the second state, setting the first cache to be in the second state, if the query result is that the first cache is in the second state, verifying whether the inventory needs to be added, if so, adding an identification information list of the relevant inventory in the second cache and setting the first cache to be in the third state, and if not, setting the first cache to be in the first state.
6. A system for cache-based inventory cutting, the system comprising:
client, stock server, distributed cache, database and management end,
the client is used for sending an inventory reduction request to the inventory server;
the inventory server side is used for disassembling original inventory data based on the inventory reduction request to obtain a plurality of inventories with unique codes;
the distributed cache is used for carrying out first cache verification on the plurality of stocks with the unique codes and carrying out second cache verification on the basis of verification results to obtain identification information of stock rows;
the database is used for operating based on the identification information of the stock row, and the management end is used for sending a message notice of a current stock change message;
the inventory server side is used for confirming inventory in the database and carrying out corresponding cache processing by monitoring the message notification;
wherein the distributed cache is to:
verifying whether the stocks with the unique codes are left or not through a distributed cache, and if the current stock is in a first state, synchronously returning to the client and simultaneously sending a message to a message notification end to confirm the state of the current stock again;
if the current stock state is the second state again, directly returning to the client, and failing to request for stock reduction;
if the current stock is in the third state, performing second cache verification;
and when the verification result is that the current stock is in the third state, directly reducing the data of the second cache to obtain the identification information of the stock row, if the identification information is empty, performing the first cache verification again and sending a stock change message notification, and if the identification information is not empty, performing the operation of the database.
7. An apparatus for cache-based inventory cutting, the apparatus comprising:
one or more processors; and
a memory having computer readable instructions stored thereon that, when executed, cause the processor to perform the operations of the method of any of claims 1 to 5.
8. A computer readable medium having computer readable instructions stored thereon which are executable by a processor to implement the method of any one of claims 1 to 5.
CN202110137445.4A 2021-02-01 2021-02-01 Cache reduction-based method, equipment and system Active CN112860746B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110137445.4A CN112860746B (en) 2021-02-01 2021-02-01 Cache reduction-based method, equipment and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110137445.4A CN112860746B (en) 2021-02-01 2021-02-01 Cache reduction-based method, equipment and system

Publications (2)

Publication Number Publication Date
CN112860746A CN112860746A (en) 2021-05-28
CN112860746B true CN112860746B (en) 2023-04-07

Family

ID=75986965

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110137445.4A Active CN112860746B (en) 2021-02-01 2021-02-01 Cache reduction-based method, equipment and system

Country Status (1)

Country Link
CN (1) CN112860746B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113935694A (en) * 2021-10-27 2022-01-14 北京京东振世信息技术有限公司 Goods inventory pre-occupation method and device and goods inventory system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105096065A (en) * 2014-04-16 2015-11-25 阿里巴巴集团控股有限公司 Inventory deduction method and inventory deduction device
CN106708975A (en) * 2016-12-06 2017-05-24 上海艾融软件股份有限公司 Commodity inventory information processing method and system
CN108133399A (en) * 2016-11-30 2018-06-08 北京京东尚科信息技术有限公司 The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces
CN108268474A (en) * 2016-12-30 2018-07-10 苏宁云商集团股份有限公司 A kind of method and device of stock control
CN111752957A (en) * 2019-03-28 2020-10-09 苏宁易购集团股份有限公司 Sale locking method and system based on caching

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105096065A (en) * 2014-04-16 2015-11-25 阿里巴巴集团控股有限公司 Inventory deduction method and inventory deduction device
CN108133399A (en) * 2016-11-30 2018-06-08 北京京东尚科信息技术有限公司 The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces
CN106708975A (en) * 2016-12-06 2017-05-24 上海艾融软件股份有限公司 Commodity inventory information processing method and system
CN108268474A (en) * 2016-12-30 2018-07-10 苏宁云商集团股份有限公司 A kind of method and device of stock control
CN111752957A (en) * 2019-03-28 2020-10-09 苏宁易购集团股份有限公司 Sale locking method and system based on caching

Also Published As

Publication number Publication date
CN112860746A (en) 2021-05-28

Similar Documents

Publication Publication Date Title
JP6749926B2 (en) Method, device and system for synchronizing data
CN108874558B (en) Message subscription method of distributed transaction, electronic device and readable storage medium
US8069224B2 (en) Method, equipment and system for resource acquisition
KR20060079078A (en) Server queuing system and method
CN111225012A (en) Transaction processing method, device and equipment
CN110008041B (en) Message processing method and device
RU2711348C1 (en) Method and system for processing requests in a distributed database
US20230030856A1 (en) Distributed table storage processing method, device and system
CN111338834B (en) Data storage method and device
CN111813868B (en) Data synchronization method and device
CN112860746B (en) Cache reduction-based method, equipment and system
CN113946427A (en) Task processing method, processor and storage medium for multi-operating system
CN112865927B (en) Message delivery verification method, device, computer equipment and storage medium
CN113326146A (en) Message processing method and device, electronic equipment and storage medium
US10728323B2 (en) Method and apparatus for operating infrastructure layer in cloud computing architecture
CN107563942B (en) Logistics data batch processing method, logistics processing system and processing device
CN114092211A (en) Processing method of accounting data, electronic device and readable storage medium
CN109976944B (en) Data processing method and system, storage medium and electronic device
CN114900531B (en) Data synchronization method, device and system
CN114257612B (en) Data processing method
CN111639089B (en) Transaction processing method, transaction processing device, electronic equipment and computer readable storage medium
CN112732757B (en) Method, system, device, equipment and storage medium for processing degraded data
CN113077241B (en) Approval processing method, device, equipment and storage medium
CN111797062B (en) Data processing method, device and distributed database system
EP4174645A1 (en) Mirror image distribution method, electronic device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Room 1101-1103, No. 433, Songhu Road, Yangpu District, Shanghai

Applicant after: Shanghai wanwansheng Environmental Protection Technology Group Co.,Ltd.

Address before: Room 1101-1103, No. 433, Songhu Road, Yangpu District, Shanghai

Applicant before: SHANGHAI YUEYI NETWORK INFORMATION TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant