Method, device and equipment for data processing and readable medium
By comparing the total inventory number and the number of shards and dynamically adjusting the inventory storage method, the performance problem of inventory deductions under high concurrency is solved, and the system's compressive resistance and availability are improved.
Patent Information
- Application Number
- CN202411388730.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-03
AI Technical Summary
In high concurrency scenarios, it is difficult for the existing technology to achieve high availability and high performance inventory deductions, and distributed lock services have performance overhead. Asynchronous processing of message queues may cause inventory deductions to expire, and the cache pressure is high, making it difficult to cope with high concurrency pressure.
By comparing the total inventory number of target objects and the total shard number of cache clusters, determine the inventory number or target shard of each shard, realize shard storage and centralized storage of inventory, and dynamically adjust the storage method to improve the system's compressive resistance ability and reduce cache pressure.
It improves the system's compressive resistance and performance, ensures high availability and robustness, and adapts to inventory management needs in high concurrency scenarios.
Smart Images

Figure CN119250701A_ABST
Abstract
Description
Technical Field
[0001] Example embodiments of the present disclosure generally relate to the field of computer technology, and more particularly, to a method, apparatus, device, and computer-readable storage medium for data processing. Background Art
[0002] With the development of Internet business, more and more scenarios involving inventory are involved. In the face of high-concurrency scenarios, how to achieve high-availability and high-performance inventory deduction is an urgent problem to be solved. Summary of the invention
[0003] In a first aspect of the present disclosure, a method for data processing is provided, comprising: comparing a total inventory number of a target object with a total number of shards of shards included in a cache cluster; in response to determining that the total inventory number is greater than or equal to the total number of shards, determining the inventory number stored in each shard in the shards included in the cache cluster based on a ratio of the total inventory number to the total number of shards, and storing the total inventory number of the target object in each shard based on the inventory number stored in each shard; and in response to determining that the total inventory number is less than the total number of shards, determining a target shard in the shards included in the cache cluster based on a first identifier of the target object, and storing the total inventory number in the target shard.
[0004] In a second aspect of the present disclosure, there is provided an apparatus for data processing, comprising: a comparison module configured to compare the total inventory number of a target object with the total number of shards of the shards included in a cache cluster; a first storage module configured to, in response to determining that the total inventory number is greater than or equal to the total number of shards, determine the inventory number stored in each shard in the shards included in the cache cluster based on a ratio of the total inventory number to the total number of shards, and store the total inventory number of the target object in each shard based on the inventory number stored in each shard; and a second storage module configured to, in response to determining that the total inventory number is less than the total number of shards, determine a target shard in the shards included in the cache cluster based on a first identifier of the target object, and store the total inventory number in the target shard.
[0005] In a third aspect of the present disclosure, an electronic device is provided. The electronic device includes at least one processing unit; and at least one memory, the at least one memory is coupled to the at least one processing unit and stores instructions for execution by the at least one processing unit, and when the instructions are executed by the at least one processing unit, the electronic device executes the method of the first aspect of the present disclosure.
[0006] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and the computer program can be executed by a processor to perform the method according to the first aspect of the present disclosure.
[0007] In a fifth aspect of the present disclosure, a computer program product is provided, comprising computer executable instructions, wherein the computer executable instructions implement the method of the first aspect of the present disclosure when executed by a processor.
[0008] It should be understood that the contents described in the summary of the invention are not intended to limit the key features or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In the following, in conjunction with the accompanying drawings and with reference to the following detailed description, the above and other features, advantages and aspects of various implementations of the present disclosure will become more apparent. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0010] Figure 1 A schematic diagram showing an example environment in which embodiments of the present disclosure can be implemented;
[0011] Figure 2 A flowchart showing a process for data processing according to some embodiments of the present disclosure is shown;
[0012] Figure 3 A flow chart showing a process for inventory handling according to some embodiments of the present disclosure;
[0013] Figure 4 A signaling interaction diagram illustrating a process for inventory handling according to some embodiments of the present disclosure is shown;
[0014] Figure 5 A block diagram showing an apparatus for data processing according to some embodiments of the present disclosure; and
[0015] Figure 6 A block diagram of an electronic device is shown in which one or more embodiments of the present disclosure may be implemented. DETAILED DESCRIPTION
[0016] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0017] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.
[0018] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0019] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0020] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information, so that the user can independently choose whether to provide personal information to software or hardware such as electronic devices, applications, servers or storage media that execute operations of the technical solution of the present disclosure based on the prompt message.
[0021] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information is sent to the user in a manner such as a pop-up window, in which the prompt information can be presented in text form. In addition, the pop-up window can also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0022] Some example embodiments of the present disclosure will be described below with reference to the accompanying drawings.
[0023] Figure 1 1 is a schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented. Figure 1 As shown, environment 100 includes electronic device 110, server 130, cache clusters 120-1, 120-2, ..., 120-X, where X is a positive integer. For ease of discussion, cache clusters 120-1, 120-2, ..., 120-X may be collectively or individually referred to as cache cluster 120.
[0024] The user can use the electronic device 110 to interact with the cache cluster 120 and the database 130 to receive or send messages, etc. Various communication client applications can be installed on the electronic device 110, such as web browser applications, shopping applications, search applications, instant communication tools, email clients, social platform software, etc.
[0025] Multiple shards may be configured in the cache cluster 120. In some embodiments, the number of cache clusters 120 and the number of shards contained in the cache cluster 120 may be set according to the system load. In some embodiments, the specifications of the cache clusters 120 may be consistent to prevent the occurrence of insufficient cache clusters 120 due to business tilt. For example, the cache cluster 120 may cache the inventory of items in a shopping website that a user browses using the electronic device 110.
[0026] The server 130 may be configured with a monitoring system 131 and a database 132. For example, the monitoring system 131 may monitor data such as inventory deduction requests provided by a shopping website browsed by a user using the electronic device 110, and send the monitored messages to the database 132 for analysis and processing. The database 132 may, for example, store the inventory of items in the shopping website browsed by the user using the electronic device 110.
[0027] The electronic device 110 may be any type of device with computing capabilities, including a terminal device or a server device. The terminal device may be any type of mobile terminal, fixed terminal or portable terminal, including a mobile phone, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a media computer, a multimedia tablet, a personal communication system (PCS) device, a personal navigation device, a personal digital assistant (PDA), an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an e-book device, a gaming device or any combination of the foregoing, including accessories and peripherals of these devices or any combination thereof. The server device may include, for example, a computing system / server, such as a mainframe, an edge computing node, an electronic device in a cloud environment, and the like.
[0028] The server 130 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks, and big data and artificial intelligence platforms. The server 130 may include, for example, a computing system / server, such as a mainframe, an edge computing node, a computing device in a cloud environment, etc. The server 130 may provide background services for shopping applications in the electronic device 110.
[0029] A communication connection may be established between the electronic device 110, the cache cluster 120, and the server 130. The communication connection may be established in a wired manner or a wireless manner. The communication connection may include, but is not limited to, a Bluetooth connection, a mobile network connection, a Universal Serial Bus (USB) connection, a Wireless Fidelity (WiFi) connection, etc., and the embodiments of the present disclosure are not limited in this respect.
[0030] It should be understood that Figure 1 The components and arrangements in the environment 100 shown are merely examples, and a computing system suitable for implementing the exemplary implementation described in the present disclosure may include one or more different components, other components, and / or different arrangements. The implementation of the present disclosure is not limited in this respect.
[0031] As described above, for high-concurrency scenarios, a distributed lock service can be used to coordinate updates to inventory, or inventory deductions can be processed asynchronously through message queues, or inventory can be stored in a cache to reduce direct access to the database.
[0032] Using distributed lock services to coordinate updates to inventory, acquiring and releasing locks will itself bring certain performance overheads. Especially in high-concurrency scenarios, lock contention may cause the time to increase, thus affecting system performance.
[0033] Inventory deductions are processed asynchronously through message queues. In the face of sudden and abnormal large traffic, if the asynchronous processing is not timely, the inventory deductions may exceed the settings.
[0034] Storing inventory through cache usually involves storing inventory in a single cluster. This puts a lot of pressure on the cache in high-concurrency scenarios.
[0035] The embodiment of the present disclosure provides a scheme for data processing. In the embodiment of the present disclosure, the total inventory number of the target object is compared with the total number of shards of the shards included in the cache cluster; in response to determining that the total inventory number is greater than or equal to the total number of shards, based on the ratio of the total inventory number to the total number of shards, the number of inventories stored in each shard in the shards included in the cache cluster is determined, and based on the number of inventories stored in each shard, the total inventory number of the target object is stored in each shard; and in response to determining that the total inventory number is less than the total number of shards, based on the first identifier of the target object, the target shard in the shards included in the cache cluster is determined, and the total inventory number is stored in the target shard. In this way, the inventory can be split and stored in the case of a large inventory number through the comparison result of the total inventory data and the total number of shards, and the inventory can be stored in a centralized manner in the case of a small inventory number, thereby improving the system's pressure resistance and reducing the cache pressure.
[0036] Some example embodiments of the present disclosure will be described below with continued reference to the accompanying drawings.
[0037] Figure 2 FIG. 2 is a flowchart of a process 200 for data processing according to some embodiments of the present disclosure. Figure 1 For example, the process 200 may be implemented at the electronic device 110 .
[0038] In block 210 , the electronic device 110 compares the total inventory number of the target object with the total number of shards included in the cache cluster 120 .
[0039] In some embodiments, the target object may be a physical item or a virtual item, and the embodiments of the present disclosure do not limit this. Taking a promotion as an example, the target object may be a preferential quota, a coupon, etc. Accordingly, the total inventory number of the target object is the total number of preferential quotas or the total number of coupons. It should be understood that a promotion may correspond to one or more target objects, and the sum of the inventory numbers of one or more target objects is the total inventory number of the target object.
[0040] For example, for a promotion activity, amount can be used to represent the total inventory quantity of the target object corresponding to the promotion activity, and activityid can be used to represent the identifier of the promotion activity, that is, one activityid corresponds to one amount. In this article, activityid can also be used to represent the identifier of the target object (that is, the first identifier of the target object mentioned below).
[0041] Assume that there are N (R1, R2, R3…R N) cache clusters 120, each cache cluster 120 includes M (P1, P2, P3...P M ) shards, the total number of shards in the cache cluster 120 is N×M. N represents the first, second, third, ..., Nth cache cluster 120, P1, P2, P3 ... P M Represents the 1st, 2nd, 3rd, …, Mth shard, where M and N are both positive integers.
[0042] When comparing the total inventory number of target objects with the total number of shards included in the cache cluster 120 , the electronic device 110 may compare the value of amount with the value of N×M.
[0043] In box 220, in response to determining that the total inventory number is greater than or equal to the total number of shards, the electronic device 110 determines the inventory number stored in each shard in the shards included in the cache cluster based on the ratio of the total inventory number to the total number of shards, and stores the total inventory number of the target object in each shard based on the inventory number stored in each shard.
[0044] In some embodiments, in response to determining that the total inventory quantity is equal to the total shard quantity, the electronic device 110 may use the following formula to determine the inventory quantity stored in each shard: pieceAmount=amount / (N*M) Among them, pieceAmount represents the number of stocks stored in the shards, N is the number of cache clusters, and M is the number of shards contained in each cache cluster.
[0045] In some embodiments, when the total inventory number is greater than the total number of shards, the ratio of the total inventory number to the total number of shards may include an integer part and a remainder part. It should be understood that if the total inventory number is divisible by the total number of shards, the remainder part is 0, and if the total inventory number is not divisible by the total number of shards, the remainder part is not 0.
[0046] When the total inventory number can be divided by the total number of shards, the above method of determining the inventory number stored in each shard when the total inventory number is equal to the total number of shards can be used to determine the inventory number stored in each shard.
[0047] When the total inventory number cannot be divided by the total number of shards, the electronic device 110 can determine the first inventory number stored in each shard in the shards included in the cache cluster based on the integer part. Further, the electronic device 110 can determine the second inventory number stored in some shards in the shards included in the cache cluster based on the remainder part. Finally, the electronic device 110 can determine the inventory number stored in each shard based on the first inventory number and the second inventory number.
[0048] For example, the first inventory quantity pieceTemp can be rounded to mount / (N*M), and the remainder is amount-pieceTemp*N*M=i. The remainder i is evenly distributed to the first i shards of the cache cluster 120, and the inventory quantity stored in each shard of the first i shards of the cache cluster 120 is: pieceAmount=pieceTemp+1, and the inventory quantity stored in the i+1th and subsequent shards is: pieceAmount=pieceTemp.
[0049] In box 230, in response to determining that the total inventory number is less than the total shard number, the electronic device 110 determines a target shard among the shards included in the cache cluster based on the first identifier of the target object, and stores the total inventory number in the target shard.
[0050] In some embodiments, the electronic device 110 may use a hash algorithm to determine a target shard among the shards included in the cache cluster based on the first identifier of the target object.
[0051] For example, the first identifier may be used as a routing key, and a hash algorithm may be used to route to the kth shard in the jth cache cluster 120 among the multiple cache clusters 120 , and the kth shard in the jth cache cluster 120 among the multiple cache clusters 120 may be determined as the target shard.
[0052] In this way, in high-concurrency scenarios, larger inventories can be split and stored, and smaller inventories can be stored centrally. At the same time, when the inventory increases or decreases, the storage method of the inventory can be dynamically adjusted according to the total inventory quantity and the total number of shards, thereby improving the system load and performance and ensuring the high availability and robustness of the system.
[0053] Figure 3 A flow chart of a process 300 for inventory processing according to some embodiments of the present disclosure is shown. The process 300 may be implemented at the electronic device 110.
[0054] In block 310 , the electronic device 110 obtains a first identifier of a target object and a second identifier of a target user.
[0055] As mentioned above, the first identifier of the target object may be an activity identifier activityid. The second identifier of the target user may be a unique identifier of the target user, such as a user name.
[0056] In block 320 , in response to determining that the total inventory number is greater than or equal to the total number of shards, the electronic device 110 determines a shard from the shards included in the cache cluster 120 based on the second identifier.
[0057] For example, the electronic device 110 can use the second identifier as a routing key and use a hash algorithm to route to a certain shard, thereby obtaining the inventory corresponding to the shard. For example, the shard can be obtained in the following manner: cachePiece i =hashTag((userName.hashCode)%N) Among them, userName represents the second identifier of the target user, cachePiece i Represents the i-th shard in the cache cluster.
[0058] In block 330 , in response to determining that the total inventory number is less than the total shard number, the electronic device 110 determines a shard from the shards included in the cache cluster based on the first identifier.
[0059] For example, the electronic device 110 can use the first identifier as a routing key and use a hash algorithm to route to a certain shard, thereby obtaining the inventory corresponding to the shard. For example, the shard can be obtained in the following manner: cachePiece i =hashTag((activityid.hashCode)%N) Among them, uactivityid represents the first identifier of the target object, cachPiece i Represents the i-th shard in the cache cluster.
[0060] In block 340 , the electronic device 110 obtains the target inventory quantity of the target object from the determined slice.
[0061] From the above mentioned content, it can be known that when the total inventory number of the target object is greater than or equal to the total number of shards included in the cache cluster 120, the target inventory number stored in the i-th shard in the cache cluster 120 is pieceAmount; when the total inventory number of the target object is less than the total number of shards included in the cache cluster 120, the target inventory number stored in the i-th shard is amount.
[0062] Further, in response to receiving the inventory reduction request for the target object, the electronic device 110 performs a reduction operation on the target inventory quantity based on the inventory reduction request. The inventory reduction request indicates a reduction quantity of the target inventory quantity for the target object.
[0063] For example, when the total inventory quantity of the target object is greater than or equal to the total number of shards included in the cache cluster 120, the electronic device 110 may perform a deduction operation on the target inventory quantity pieceAmount based on the inventory deduction request.
[0064] For example, when the total inventory quantity of the target object is less than the total number of shards included in the cache cluster 120 , the electronic device 110 may perform a deduction operation on the target inventory quantity amount based on the inventory deduction request.
[0065] In some embodiments, before the electronic device 110 performs a deduction operation on the target inventory quantity based on the inventory deduction request, it is also necessary to determine whether the balance of the target inventory quantity is sufficient. If the balance is sufficient, the deduction operation can be performed directly. If the balance is insufficient, a prompt message can be sent to the user, or the target inventory quantity can be re-determined to ensure that the inventory balance is sufficient.
[0066] Furthermore, before executing the deduction operation, the electronic device 110 may obtain an anti-duplicate identifier from the cache cluster 120, and determine whether the current deduction operation on the target inventory quantity is repeated based on the anti-duplicate identifier. In response to determining that the current deduction operation is not repeated, a deduction operation on the target inventory quantity based on the inventory deduction request is executed.
[0067] For example, the electronic device 110 can use a combination of a remote dictionary server (Remote Dictionary Server, Redis) and a lightweight, embedded scripting language Lua to determine whether the current deduction operation on the target inventory quantity is repeated. When the remote dictionary server executes the Lua scripting language, it ensures that all commands in the script are executed in sequence and will not be interrupted by other commands, thereby ensuring atomicity.
[0068] In some embodiments, after performing a deduction operation on the target inventory quantity in the cache cluster 120, the electronic device 110 may send an inventory deduction message for the target object to the database 132, so that the database updates the total inventory quantity of the target object based on the inventory deduction message. The inventory deduction message indicates the deduction quantity of the target inventory quantity for the target object and the success of the deduction operation. In some embodiments, the inventory deduction message sent by the electronic device 110 to the database 132 may be an asynchronous message.
[0069] In summary, the embodiments of the present disclosure can, in a high-concurrency scenario, split and store the inventory when the inventory number is large, and store the inventory in a centralized manner when the inventory number is small, by comparing the total inventory data of the target object with the total number of shards of the cache cluster. At the same time, when the inventory increases or decreases, the storage method of the inventory can be dynamically adjusted according to the total inventory number and the total number of shards, thereby improving the system's stress resistance, reducing cache pressure, and ensuring the high availability and robustness of the system.
[0070] Some example embodiments of the present disclosure will be described below in conjunction with specific examples.
[0071] Figure 4 A signaling interaction diagram of a process 400 for inventory handling according to some embodiments of the present disclosure is shown.
[0072] In block 401, when a user participates in a promotional activity, the electronic device 110 determines whether the user meets the transaction rules.
[0073] For example, the transaction rule may be the first 100 users who participated in the promotion, that is, the electronic device 110 determines whether the user is one of the first 100 users who participated in the promotion. For another example, the transaction rule may also be that the user has a coupon, and the electronic device 100 may determine whether the user uses the coupon when trading.
[0074] In block 402 , when the user meets the transaction rules, the electronic device 110 sends a request to the cache cluster 120 to obtain an anti-duplicate identifier.
[0075] In block 403 , the electronic device 110 receives an anti-duplication identifier returned by the cache cluster 120 .
[0076] In block 404 , the electronic device 110 determines whether the transaction is a duplicate transaction based on the anti-duplicate flag.
[0077] At block 405 , after determining that the transaction is not a duplicate transaction, the electronic device 110 selects a routing key.
[0078] For example, when the total inventory number of target objects is greater than or equal to the total number of shards included in the cache cluster 120, the electronic device 110 may select the second identifier of the target user as the routing kye; when the total inventory number of target objects is less than the total number of shards included in the cache cluster 120, the electronic device 110 may select the first identifier of the target object as the routing kye.
[0079] In block 406 , the electronic device 110 sends a request to the cache cluster 120 to obtain the inventory balance in the shard based on the routing key.
[0080] In block 407 , the electronic device receives the inventory returned by the cache cluster 120 .
[0081] At block 408 , the electronic device 110 determines whether the inventory is sufficient.
[0082] In block 409 , when the inventory is sufficient, the electronic device 110 sends a request to reduce the inventory to the cache cluster 120 .
[0083] In block 410 , the electronic device 110 receives a message indicating that the deduction is successful, which is returned by the cache cluster 120 .
[0084] At block 411 , the electronic device 110 sends an inventory reduction message to the monitoring system 131 .
[0085] In block 412 , after receiving the inventory reduction message, the monitoring system 131 sends a database information change message to the database 132 , so that the database 132 updates the total inventory quantity of the target object based on the database information change message.
[0086] Figure 5 A block diagram of an apparatus 500 for data processing according to some embodiments of the present disclosure is shown. The apparatus 500 may be implemented as or include the electronic device 110.
[0087] The device 500 includes a comparison module 510, which is configured to compare the total inventory number of the target object with the total number of shards of the shards included in the cache cluster. The device 500 also includes a first storage module 520, which is configured to determine the inventory number stored in each shard in the shards included in the cache cluster based on the ratio of the total inventory number to the total number of shards in response to determining that the total inventory number is greater than or equal to the total number of shards, and store the total inventory number of the target object in each shard based on the inventory number stored in each shard. The device 700 also includes a second storage module 530, which is configured to determine the target shard in the shards included in the cache cluster based on the first identifier of the target object in response to determining that the total inventory number is less than the total number of shards, and store the total inventory number in the target shard.
[0088] In some embodiments, the ratio includes an integer part and a remainder part, and the first storage module 520 is further configured to determine, based on the integer part, a first inventory number stored in each shard in the cache cluster; based on the remainder part, determine a second inventory number stored in some shards in the shards included in the cache cluster; and based on the first inventory number and the second inventory number, determine the inventory number stored in each shard.
[0089] In some embodiments, the second storage module 530 is further configured to determine the target shard among the shards included in the cache cluster based on the first identifier of the target object by using a hash algorithm.
[0090] In some embodiments, the device 500 also includes an acquisition module configured to acquire a first identifier of the target object and a second identifier of the target user; in response to determining that the total inventory number is greater than or equal to the total number of shards, determine a shard in the shards included in the cache cluster based on the second identifier; in response to determining that the total inventory number is less than the total number of shards, determine a shard in the shards included in the cache cluster based on the first identifier; and acquire the target inventory number of the target object from the determined shard.
[0091] In some embodiments, the device 500 also includes a deduction module, which is configured to perform a deduction operation on the target inventory quantity based on the inventory deduction request in response to receiving an inventory deduction request for the target object, wherein the inventory deduction request indicates a deduction amount from the target inventory quantity for the target object.
[0092] In some embodiments, the device 500 also includes a determination module configured to obtain an anti-duplicate identifier from a cache cluster; determine whether a current deduction operation on a target inventory quantity is repeated based on the anti-duplicate identifier; and in response to determining that the current deduction operation is not repeated, execute a deduction operation on the target inventory quantity based on the inventory deduction request.
[0093] In some embodiments, the device 500 also includes a sending module, which is configured to send an inventory deduction message for the target object to the database, so that the database updates the total inventory quantity of the target object based on the inventory deduction message, and the inventory deduction message indicates the deduction number of the target inventory quantity for the target object and the successful execution of the deduction operation.
[0094] The modules included in the device 500 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more units can be implemented using software and / or firmware, such as machine executable instructions stored on a storage medium. In addition to or as an alternative to machine executable instructions, some or all of the units in the device 500 can be implemented at least in part by one or more hardware logic components. As an example and not limitation, exemplary types of hardware logic components that can be used include field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0095] Figure 6 1 shows a block diagram of an electronic device 600 in which one or more embodiments of the present disclosure may be implemented. It should be understood that Figure 6 The electronic device 600 shown is merely exemplary and should not constitute any limitation on the functionality and scope of the embodiments described herein.
[0096] like Figure 6 As shown, the electronic device 600 is in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to, one or more processors or processing units 610, a memory 620, a storage device 630, one or more communication units 640, one or more input devices 650, and one or more output devices 660. The processing unit 610 may be an actual or virtual processor and is capable of performing various processes according to a program stored in the memory 620. In a multi-processor system, multiple processing units execute computer executable instructions in parallel to improve the parallel processing capabilities of the electronic device 600.
[0097] The electronic device 600 typically includes a plurality of computer storage media. Such media may be any available media accessible to the electronic device 600, including but not limited to volatile and non-volatile media, removable and non-removable media. The memory 620 may be a volatile memory (e.g., a register, a cache, a random access memory (RAM)), a non-volatile memory (e.g., a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof. The storage device 630 may be a removable or non-removable medium, and may include a machine-readable medium, such as a flash drive, a disk, or any other medium, which may be capable of being used to store information and / or data (e.g., training data for training) and may be accessed within the electronic device 600.
[0098] The electronic device 600 may further include additional removable / non-removable, volatile / non-volatile storage media. Figure 6 As shown in , a disk drive for reading or writing from a removable, non-volatile disk (e.g., a "floppy disk") and an optical drive for reading or writing from a removable, non-volatile optical disk may be provided. In these cases, each drive may be connected to the bus (not shown) by one or more data media interfaces. The memory 620 may include a computer program product 625 having one or more program modules that are configured to perform various methods or actions of various embodiments of the present disclosure.
[0099] The communication unit 640 implements communication with other electronic devices through a communication medium. Additionally, the functions of the components of the electronic device 600 can be implemented with a single computing cluster or multiple computing machines that can communicate through a communication connection. Therefore, the electronic device 600 can operate in a networked environment using a logical connection with one or more other servers, a network personal computer (PC), or another network node.
[0100] The input device 650 may be one or more input devices, such as a mouse, a keyboard, a tracking ball, etc. The output device 660 may be one or more output devices, such as a display, a speaker, a printer, etc. The electronic device 600 may also communicate with one or more external devices (not shown) through the communication unit 640 as needed, such as a storage device, a display device, etc., communicate with one or more devices that allow a user to interact with the electronic device 600, or communicate with any device that allows the electronic device 600 to communicate with one or more other electronic devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface (not shown).
[0101] According to an exemplary implementation of the present disclosure, a computer-readable storage medium is provided, on which one or more computer instructions are stored, wherein the one or more computer instructions are executed by a processor to implement the method described above. According to an exemplary implementation of the present disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, and the computer-executable instructions are executed by a processor to implement the method described above.
[0102] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products implemented according to the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0103] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0104] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0105] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple implementations of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of a module, program segment or instruction includes one or more executable instructions for realizing the logical function of the specification. In some implementations as replacements, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a special hardware-based system that performs the function or action of the specification, or can be realized by a combination of special hardware and computer instructions.
[0106] The above descriptions of various implementations of the present disclosure are exemplary, non-exhaustive, and not limited to the disclosed implementations. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described implementations. The selection of terms used herein is intended to best explain the principles of the implementations, practical applications, or improvements to the technology in the marketplace, or to enable other persons of ordinary skill in the art to understand the implementations disclosed herein.
Claims
1. A method for data processing, comprising: Compare the total inventory count of the target object with the total number of shards in the cache cluster; In response to determining that the total inventory number is greater than or equal to the total shard number, Based on the ratio of the total inventory quantity to the total number of shards, determine the inventory quantity stored in each shard in the shards included in the cache cluster, and Based on the inventory quantities stored in the respective shards, storing the total inventory quantity of the target object in the respective shards; as well as In response to determining that the total inventory number is less than the total shard number, Based on the first identifier of the target object, determine a target shard among the shards included in the cache cluster, and The total inventory quantity is stored in the target shard.
2. The method according to claim 1, wherein the ratio includes an integer part and a remainder part, and wherein based on the ratio of the total inventory number to the total number of shards, determining the number of inventories stored in each shard in the shards included in the cache cluster comprises: Based on the integer part, determine the first inventory quantity stored in each shard in the shards included in the cache cluster; Based on the remainder, determine the number of second inventories stored in some of the shards included in the cache cluster; as well as Based on the first inventory quantity and the second inventory quantity, the inventory quantity stored in each shard is determined.
3. The method according to claim 1, wherein based on the first identifier of the target object, determining the target shard among the shards included in the cache cluster comprises: The target shard among the shards included in the cache cluster is determined based on the first identifier of the target object by using a hash algorithm.
4. The method according to claim 1, further comprising: Acquire the first identifier of the target object and the second identifier of the target user; In response to determining that the total inventory number is greater than or equal to the total number of shards, determining a shard from the shards included in the cache cluster based on the second identifier; In response to determining that the total inventory number is less than the total number of shards, determining a shard from the shards included in the cache cluster based on the first identifier; as well as The target inventory quantity of the target object is obtained from the determined shards.
5. The method according to claim 4, further comprising: In response to receiving a stock reduction request for the target object, a reduction operation is performed on the target inventory quantity based on the stock reduction request, the stock reduction request indicating a reduction quantity of the target inventory quantity for the target object.
6. The method according to claim 5, further comprising: Obtaining an anti-duplicate identifier from the cache cluster; Based on the anti-duplicate identifier, determining whether a current deduction operation on the target inventory quantity is repeated; as well as In response to determining that the current deduction operation is not repeated, performing the deduction operation on the target inventory amount based on the inventory deduction request.
7. The method according to claim 5, further comprising: Sending a stock deduction message for the target object to a database, so that the database updates the total stock quantity of the target object based on the stock deduction message, wherein the stock deduction message indicates a deduction quantity from the target stock quantity of the target object and that the deduction operation is successfully executed.
8. A device for data processing, comprising: A comparison module is configured to compare a total inventory number of the target object with a total number of shards of the shards included in the cache cluster; A first storage module is configured to, in response to determining that the total inventory number is greater than or equal to the total shard number, Based on the ratio of the total inventory quantity to the total number of shards, determine the inventory quantity stored in each shard in the shards included in the cache cluster, and Based on the inventory quantities stored in the respective shards, storing the total inventory quantity of the target object in the respective shards; as well as A second storage module is configured to, in response to determining that the total inventory number is less than the total shard number, Based on the first identifier of the target object, determine a target shard among the shards included in the cache cluster, and The total inventory quantity is stored in the target shard.
9. An electronic device, comprising: at least one processing unit; as well as At least one memory, the at least one memory is coupled to the at least one processing unit and stores instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, causing the electronic device to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program can be executed by a processor to implement the method according to any one of claims 1 to 7.
11. A computer program product comprising computer executable instructions, wherein the computer executable instructions, when executed by a processor, implement the method according to any one of claims 1 to 7.
