CN112527826A - Method and device for processing request - Google Patents

Method and device for processing request Download PDF

Info

Publication number
CN112527826A
CN112527826A CN201910887393.5A CN201910887393A CN112527826A CN 112527826 A CN112527826 A CN 112527826A CN 201910887393 A CN201910887393 A CN 201910887393A CN 112527826 A CN112527826 A CN 112527826A
Authority
CN
China
Prior art keywords
request
requests
processing
processed
database
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.)
Pending
Application number
CN201910887393.5A
Other languages
Chinese (zh)
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.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
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 Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN201910887393.5A priority Critical patent/CN112527826A/en
Publication of CN112527826A publication Critical patent/CN112527826A/en
Pending legal-status Critical Current

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/2453Query optimisation
    • 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/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors

Abstract

The invention discloses a method and a device for processing a request, and relates to the technical field of computers. One embodiment of the method comprises: receiving a plurality of requests, the requests including identification information; screening out the requests with the same identification information from the plurality of requests as the same requests; and acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and discarding part of requests in the same request. The implementation mode reduces resources consumed by repeated calculation, improves the processing performance, ensures the timeliness of processing, and improves the user experience.

Description

Method and device for processing request
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a request.
Background
In many cases, store inventory calculations are triggered, such as changes in the ratio of store inventory to warehouse inventory, changes in warehouse inventory, and the like. If the warehouse inventory and/or the proportion of the store inventory to the warehouse inventory changes many times in the same time or in a short time, the prior art processing method is to calculate the store inventory for each change.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
in the processing process of the prior art, only the last calculation is effective, the calculation except the last calculation consumes resources, and under the high concurrency condition, the problem of low processing performance exists, and under the extreme condition, the calculation cannot be performed, so that the user experience degree is influenced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for processing a request, which can reduce resources consumed by repeated computations and improve processing performance and user experience.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of processing a request.
The method for processing the request of the embodiment of the invention comprises the following steps:
receiving a plurality of requests, the requests including identification information;
screening out the requests with the same identification information from the plurality of requests as the same requests;
and acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and discarding part of requests in the same request.
In one embodiment, acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and discarding part of requests in the same request includes:
sequentially arranging each request in the same request according to the time stamp;
reserving the request closest to the current timestamp, and giving up other requests;
and acquiring corresponding data to be processed from a database according to the identification information of the request closest to the current timestamp, processing the data to be processed, and storing a processing result in the database.
In one embodiment, before reserving the request closest to the current timestamp and discarding other requests, the method further comprises:
and if the interval of the time stamps of any adjacent request is larger than a preset value, acquiring corresponding data to be processed from a database according to the identification information of one request in the adjacent requests, processing the data to be processed, and storing a processing result in the database.
In one embodiment, the identification information includes product information, store information, and warehouse information in which the product is stored;
after receiving the plurality of requests, further comprising:
and screening out different requests of any one of the product information, the shop information and the warehouse information for storing the product from the requests to serve as different requests, respectively acquiring corresponding data to be processed from a database according to identification information of the different requests, processing the data to be processed, and storing a processing result in the database.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for processing a request.
The device for processing the request of the embodiment of the invention comprises:
a receiving unit configured to receive a plurality of requests, the requests including identification information;
a selecting unit configured to screen out, from the plurality of requests, requests having the same identification information as a same request;
and the processing unit is used for acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and abandoning part of requests in the same request.
In one embodiment, the processing unit is specifically configured to:
sequentially arranging each request in the same request according to the time stamp;
reserving the request closest to the current timestamp, and giving up other requests;
and acquiring corresponding data to be processed from a database according to the identification information of the request closest to the current timestamp, processing the data to be processed, and storing a processing result in the database.
In one embodiment, the processing unit is specifically further configured to:
and before the request closest to the current timestamp is reserved and other requests are abandoned, if the interval of the timestamps of any adjacent requests is greater than a preset value, acquiring corresponding data to be processed from a database according to the identification information of one request in the adjacent requests, processing the data to be processed, and storing the processing result in the database.
In one embodiment, the identification information includes product information, store information, and warehouse information in which the product is stored;
the selection unit is specifically configured to: after receiving a plurality of requests, screening out any different request of the product information, the shop information and the warehouse information for storing the product from the plurality of requests as different requests;
the processing unit is specifically further configured to: and respectively acquiring corresponding data to be processed from a database according to the identification information of the different requests, processing the data to be processed, and storing a processing result in the database.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the method for processing the request provided by the embodiment of the invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention stores thereon a computer program, which when executed by a processor implements the method for processing a request provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the same request is screened from a plurality of requests through the identification information, corresponding data to be processed is obtained from the database according to the identification information of the same request, the data to be processed is processed, a processing result is stored in the database, and partial requests in the same request are abandoned, so that resources consumed by repeated calculation are reduced in a mode of abandoning partial requests in the same request under the condition of ensuring the processing result. More requests can be processed under the high concurrency condition, and the request processing speed is higher, so that the processing performance is improved, a user can quickly obtain the processing result of the same request, the processing timeliness is ensured, and the user experience is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a main flow of a method of processing a request according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a main flow of a method of processing a request according to another embodiment of the invention;
FIG. 3 is a schematic diagram of a main flow of a method of processing a request according to yet another embodiment of the invention;
FIG. 4 is a schematic diagram of the main elements of an apparatus for processing requests according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
In many cases, store inventory calculations are triggered, such as changes in the ratio of store inventory to warehouse inventory, changes in warehouse inventory, and the like. The stock quantity of the stores is calculated on the basis of single products. If the warehouse inventory and/or the proportion of the store inventory to the warehouse inventory changes many times in the same time or in a short time, the prior art processing mode is to calculate and store the store inventory for each change. For example, at the same time, the stock of warehouse a changes from 100 to 200, and the proportion of store B stock in warehouse a stock changes from 20% to 40%, then the prior art process is: obtaining 200 and 40%, performing a calculation by 200 × 40%, and storing the stock amount 80 of the store B; the 200 and 40% are retrieved again, and the calculation is performed once at 200 × 40%, and the stock amount 80 of the shop B is stored. Thus, the first acquisition of 200 and 40%, the calculation performed once at 200 × 40%, and the process of storing the inventory amount 80 of the shop B is repeated. For another example, in a short time, the stock quantity of warehouse a is changed from 100 to 200, and then from 200 to 300, and the stock of store B accounts for 10% of the stock of warehouse a. The treatment process in the prior art is as follows: obtaining 200 and 10%, performing a calculation at 200 × 10%, and storing the stock amount 20 of the store B; further, 300% and 10% are acquired, and calculation is performed once at 300 × 10%, and the stock amount 30 of the store B is stored. Thus, 200 and 10% are acquired for the first time, a calculation is performed at 200 × 10%, and the process of storing the inventory amount 20 of the store B is repeated.
In the processing process of the prior art, only the last calculation is effective, the calculation except the last calculation consumes resources, and under the high concurrency condition, the problem of low processing performance still exists, and under the extreme condition, the product over-sale is caused by the incapability of calculation, and the user experience degree is influenced.
To solve the problems in the prior art, an embodiment of the present invention provides a method for processing a request, which may be performed by a server, as shown in fig. 1, and includes:
step S101, receiving a plurality of requests, wherein the requests comprise identification information.
In this step, when the ratio of the store inventory in the database to the warehouse inventory changes, or the warehouse inventory amount changes, or the like, the database generates a request for calculating the store inventory amount, and the database transmits the request to the server. Thus, the server may receive at least one request.
And step S102, screening out the requests with the same identification information from the plurality of requests as the same requests.
It should be noted that, in the prior art, the requests for calculating the stock quantity are not distinguished, so that the problem of resource waste caused by repeated calculation exists. The embodiment of the invention distinguishes which requests are the same requests and which requests are different requests through the identification information. Therefore, the same request is processed differently from the different requests, and the problem of resource waste caused by repeated calculation is reduced.
Step S103, acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and abandoning part of requests in the same request.
In the step, when the method is implemented specifically, the latest ratio of the store inventory to the warehouse inventory and the latest warehouse inventory are acquired from the database according to the identification information of the same request, the store inventory is obtained by multiplying the latest ratio of the store inventory to the warehouse inventory, the store deposit amount is stored in the database, and part of the requests in the same request are abandoned. The partial requests may be requests other than the request closest to the current timestamp in the same request. It should be understood that the embodiments of the present invention discard requests other than the request closest to the current timestamp in the same request, and those skilled in the art can flexibly set which requests to discard without affecting the embodiments of the present invention.
In the embodiment, the same request is screened from a plurality of requests through the identification information, corresponding data to be processed is obtained from the database according to the identification information of the same request, the data to be processed is processed, a processing result is stored in the database, and partial requests in the same request are abandoned, so that resources consumed by repeated calculation are reduced in a mode of abandoning the partial requests in the same request under the condition of ensuring the processing result. More requests can be processed under the high concurrency condition, and the request processing speed is higher, so that the processing performance is improved, a user can quickly obtain the processing result of the same request, the processing timeliness is ensured, and the user experience is improved.
To solve the problems in the prior art, another embodiment of the present invention provides a method for processing a request, which may be performed by a server, as shown in fig. 2, and includes:
step S201, receiving a plurality of requests, wherein the requests include identification information.
Step S202, the identification information comprises product information, shop information and warehouse information for storing the product; and screening out different requests of any one of the product information, the shop information and the warehouse information for storing the product from the requests to serve as different requests, respectively acquiring corresponding data to be processed from a database according to identification information of the different requests, processing the data to be processed, and storing a processing result in the database.
In this step, the step is described as a specific example: the product information in request 1 is product 1 and the product information in request 2 is product 2, so that the screened request 1 and the screened request 2 are different requests. Acquiring the latest warehouse stock of the product 1 and the ratio of the latest shop stock of the product 1 to the warehouse stock from the database according to the identification information of the request 1, multiplying the latest warehouse stock of the product 1 and the warehouse stock to obtain the shop stock of the product 1, and storing the shop stock of the product 1 in the database; and obtaining the latest warehouse stock of the product 2 and the ratio of the latest shop stock of the product 2 to the warehouse stock from the database according to the identification information of the request 2, multiplying the latest warehouse stock of the product 2 by the latest warehouse stock to obtain the shop stock of the product 2, and storing the shop stock of the product 2 in the database.
It should be noted that, the corresponding data to be processed is obtained from the database through each identification information of different requests, the data to be processed is processed, and the processing result is stored in the database, so that the processing of all the requests is completed, and the integrity of the processing is ensured.
Step S203, the requests with the same identification information are screened out from the plurality of requests and used as the same requests.
In this step, it should be noted that the request with the same information in the identification information is the same request, and a request with different information is not the same request.
And step S204, sequencing each request in the same request according to the time stamp.
In this step, in implementation, each of the same requests is sorted in a descending order according to a timestamp, or each of the same requests is sorted in an ascending order.
Step S205, if the interval of the time stamps of any adjacent request is larger than a preset value, acquiring corresponding data to be processed from a database according to the identification information of one request in the adjacent requests, processing the data to be processed, and storing the processing result in the database.
In this step, the size of the preset value may be set as desired, for example, 30 seconds. In addition, if the interval of the time stamps of any adjacent request is too large, one-time calculation is forcibly executed, namely, corresponding data to be processed is acquired from the database according to the identification information of one request in the adjacent requests, the data to be processed is processed, and the processing result is stored in the database. Therefore, the problem that the user cannot obtain the processing result due to continuous abandoning of the request is avoided, the processing timeliness is guaranteed, and the user experience degree is improved.
In specific implementation, the latest ratio of the store inventory to the warehouse inventory and the latest warehouse inventory are obtained from the database according to the identification information of one request in the adjacent requests, the store deposit amount is obtained by multiplying the latest ratio of the store inventory to the warehouse inventory, and the store deposit amount is stored in the database.
It should be noted that, if the time stamp intervals of all the adjacent requests are less than or equal to the preset value, step S206 is executed.
Step S206, the request closest to the current time stamp is reserved, and other requests are abandoned.
In this step, the other requests refer to requests other than the one closest to the current timestamp in the same request.
It should be noted that, by sequentially ordering each request in the same request according to the timestamp, the request closest to the current timestamp is retained, and other requests are discarded. In the case of guaranteeing the processing result, the resources consumed by the repetitive computation are reduced in such a manner that requests other than the request closest to the current time stamp in the same request are discarded. More requests can be processed under the high concurrency condition, and the request processing speed is higher, so that the processing performance is further improved, a user can quickly obtain the processing result of the same request, the processing timeliness is further ensured, and the user experience is further improved.
Step S207, acquiring corresponding data to be processed from a database according to the identification information of the request closest to the current timestamp, processing the data to be processed, and storing a processing result in the database.
In the step, in concrete implementation, the latest ratio of the store inventory to the warehouse inventory is obtained from the database according to the product information and the store information of the request closest to the current timestamp, the latest warehouse inventory is obtained according to the product information and the warehouse information of the stored product, the latest ratio of the store inventory to the warehouse inventory and the latest warehouse inventory are multiplied to obtain the store inventory of the product, and the store inventory of the product is stored in the database.
In addition, the product information may include: product name, product number or product manufacturer, etc. The store information may include: store name, store organization code, store corporate name, and the like. In addition, the ratio of the store inventory to the warehouse inventory is stored in the database, and the database stores not only the ratio of the store inventory before change to the warehouse inventory but also the ratio of the store inventory after change to the warehouse inventory, and therefore, in order to increase the speed of the processing request and improve the processing performance, it is necessary to acquire the latest ratio of the store inventory to the warehouse inventory. Further, storing warehouse information of the product may include: warehouse name, warehouse code, warehouse accountant name, and the like. In addition, the stock quantity of the warehouse is stored in the database, and the database stores not only the stock quantity of the warehouse before the change but also the stock quantity of the warehouse after the change, and therefore, in order to increase the speed of the processing request and improve the processing performance, it is necessary to acquire the latest stock quantity of the warehouse.
In order to solve the problems of the prior art, a method for processing a request according to still another embodiment of the present invention is described below as a specific example, where the method is executed by a server, which may be specifically a store inventory calculation server.
It is to be noted that warehouse a is assumed to store product 1(EMG1 is product 1), product 2(EMG2 is product 2), and product 3(EMG3 is product 3). The stock level of product 1 in warehouse A is 100, the stock level of product 2 in warehouse A is 150, and the stock level of product 3 in warehouse A is 200. Warehouse a inventory, see table 1 below:
storage house Product(s) Stock of warehouse
A EMG1 100
A EMG2 150
A EMG3 200
TABLE 1 warehouse A inventory
Wherein store B sells product 1, product 2, and product 3, store C sells product 2 and product 3, and store D sells product 1. The relationship of stores, products and warehouses, see table 2 below:
shop Storage house Product(s)
B A EMG1
B A EMG2
B A EMG3
C A EMG2
C A EMG3
D A EMG1
TABLE 2 relationship table of stores, products and warehouses
The ratio of store inventory to warehouse inventory for each store is shown in table 3 below:
shop number Warehouse numbering Ratio of
B A 20%
C A 40%
D A 40%
TABLE 3 proportion table of store inventory to warehouse inventory
Wherein, for each product, the store inventory amount (N) is the warehouse inventory amount (M) x the ratio of the store inventory to the warehouse inventory (L). For example, the stock amount of the store B of the product 1 is 100 (stock amount of the warehouse of the product 1) × 20% (the proportion of the stock of the store B of the product 1 in the stock amount of the warehouse) is 20. The stock of each store for each product is calculated according to the above formula, see table 4 below:
shop Product(s) Store inventory of products
B ESG1 20
B ESG2 30
B ESG3 40
C ESG2 60
C ESG3 80
D ESG1 40
TABLE 4 inventory table of each store for each product
The shop B, the shop C and the shop D sell the products of the respective shops at the same time, and complete the order out of the warehouse, and deduct the shop stock and the warehouse stock. After a period of time, EMG1, EMG2, and EMG3 in warehouse a are sold out. The newly purchased EMG1, EMG2, and EMG3 are stored in warehouse a, and the warehouse a inventory amount is saved into the database. Meanwhile, since the number of products sold by the shop B is larger than that of the shop C and the shop D, the ratio of the shop B inventory to the warehouse inventory is increased, the ratio of the shop C inventory to the warehouse inventory and the ratio of the shop D inventory to the warehouse inventory are decreased, and the changed ratios are stored in the database. As described above, the warehouse inventory and the ratio of the store inventory to the warehouse inventory change simultaneously, and therefore, the database generates request 1 due to the inventory of warehouse a, request 2 due to the ratio of the inventory of store B to the warehouse inventory, request 3 due to the ratio of the inventory of store C to the warehouse inventory, and request 4 due to the ratio of the inventory of store D to the warehouse inventory, and transmits request 1, request 2, request 3, and request 4 to the server.
The following describes the process of processing request 1 and request 2, taking product 1 and store B as examples, as follows:
step 1, obtaining product information (EMG1) and warehouse information (a) of the stored product 1 from the request 1, and constructing a KEY (KEY) of the request 1 according to the product information and the warehouse information, for example, the KEY of the request 1 is EMG1+ a. Product information (EMG1) and warehouse information (a) storing the product 1 are obtained from the request 2, and a KEY for the request 2 is constructed from the product information and the warehouse information, for example, KEY of the request 2 is EMG1+ a.
In this step, since the calculation of the stock quantity of the store is performed with a single product, and the request may include information on a plurality of products, the request is broken down into requests for a single product. Similarly, the calculation of the stock quantity of the stores is performed by a single store, and the request may include a plurality of store information, so that the request is divided into the requests of the single stores.
Step 2, since the keyword of the request 1 is the same as the keyword of the request 2, it is confirmed that the request 1 and the request 2 are the same, and the server receives the request 1 first and then receives the request 2. Thus, the sequence number of the KEY (KEY) of request 1 is set to 1; the KEY (KEY) of request 2 has a sequence number set to 2 and sequence number 2 is set to the specified sequence number.
In this step, in implementation, the sequence number of the keyword of the last received request may be set as the designated sequence number. It should be understood that a person skilled in the art can flexibly set the designated sequence number without affecting the embodiments of the present invention. It should be noted that, by setting the designated sequence number, the sequence number of each request in the same request is verified by the designated sequence number, and when the sequence number of the request is verified to be different from the designated sequence number, the request is not processed, thereby saving resources. It should be understood that the specified sequence number must be the sequence number of the key of one of the same requests.
Step 3, filling the requested keyword and the serial number thereof into a pre-constructed message queue according to the serial number of the requested keyword, wherein the message queue is shown in the following table 5:
Figure BDA0002207733490000121
TABLE 5 message queue List
Step 4, taking out the data of the first row from the message queue, verifying whether the sequence number of the KEY of the request 1 is equal to the designated sequence number or not, and verifying that the sequence number of the KEY of the request 1 is smaller than the designated sequence number; and then taking out the data of the second row from the message queue, verifying whether the sequence number of the KEY of the request 2 is equal to the specified sequence number or not, and verifying that the sequence number of the KEY of the request 2 is equal to the specified sequence number.
In this step, it may be determined whether or not the interval between the time when the stock quantity of the store B of the product 1 was last stored in the database and the time when the KEY number of the verification request 1 was last stored is greater than 30 seconds (it should be understood that 30 seconds is preset, and embodiments of the present invention may set different times according to specific businesses), and if so, the latest stock quantity of the product 1 and the ratio of the latest stock quantity of the store B of the product 1 to the stock quantity of the store B of the product 1 are obtained from the database according to the product information (EMG1), the store information (store B), and the warehouse information (a) in the request 1, and the latest stock quantity of the store B of the product 1 is multiplied by the ratio of the latest stock quantity of the store B of the product 1 to the stock quantity of the store B of the product 1 to obtain the stock quantity of the store B of the product 1, and the stock quantity of the. Therefore, the situation that the user cannot obtain the store stock of the product due to continuous abandon requests is reduced, the store stock of the product is timely saved, and the timeliness of processing is guaranteed.
And step 5, acquiring the latest warehouse stock of the product 1 and the ratio of the latest store B stock of the product 1 to the warehouse stock from the database according to the product information (EMG1), the store information (store B) and the warehouse information (A) in the request 2, and multiplying the latest warehouse stock of the product 1 and the ratio of the latest store B stock of the product 1 to the warehouse stock to obtain the store B stock of the product 1.
In this step, it should be noted that step 5 may be performed before step 4, that is, the request is processed first, and then the serial number of the KEY of the request is verified, so that both the request 1 and the request 2 are processed according to step 5, and the processing results of both are the same, which results in resource waste due to repeated calculation. Therefore, preferably, step 4 is performed first, and then step 5 is performed, so as to avoid the problem of resource waste.
And 6, after the stock of the shop B of the product 1 is calculated, verifying whether the number of the KEY of the request 2 is equal to the designated number again, and if the number of the KEY is equal to the designated number, storing the stock of the shop B of the product 1 in the database.
In this step, after the stock quantity of the shop B of the product 1 is stored in the database, it may be transmitted to another system, for example, a system that needs the stock quantity of the shop B of the product 1. Since the verification is performed once again before the product 1 is saved in the database, the stock of the store B of the product 1 is not saved in the database when the verification is not equal to the verification, and resources written in the database are saved.
As shown in fig. 3, a method for processing a request according to another embodiment of the present invention is further described as follows:
it should be noted that the server has three service threads: service thread 1, service thread 2, and service thread 3.
Step 301, sequentially receives request 1 (product information is EMG1, store information is store B, warehouse information of stored product is warehouse a), request 2 (product information is EMG2, store information is store B, warehouse information of stored product is warehouse a), request 3 (product information is EMG1, store information is store B, warehouse information of stored product is warehouse a), and request 4 (product information is EMG3, store information is store B, warehouse information of stored product is warehouse a).
Step 302, the service thread 1 encodes the EMG1 in request 1, and the serial number of the EMG1 in request 1 is 1.
In this step, the encoding rule of the service thread is described with a specific example: the product of request 1 has a serial number of 1, the product of request 2 has a serial number of 2, and the product of request 3 has a serial number of 1. Wherein, the sequence of receiving the requests from first to last is as follows: request 1, request 2, and request 3; request 1 and request 2 are the same request and request 3 is a different request.
Step 303, the service thread 2 encodes the EMG2 in the request 2, and the serial number of the EMG2 in the request 2 is 1.
Step 304, the service thread 3 encodes the EMG1 in the request 3, and the sequence number of the EMG1 in the request 3 is 2;
step 305, the service thread 1 determines that the request 1 and the request 3 are the same request according to the product information, the store information and the warehouse information of the stored product in the request 1 and the request 3, the serial number 1 of the EMG1 in the request 1 is not equal to the serial number 2 of the EMG1 in the request 3, and the service thread 1 abandons the request 1.
Step 306, the service thread 1 encodes the EMG3 in the request 4, and the sequence number of the EMG3 in the request 4 is 1.
Step 307, the service thread 1 determines that the serial number 1 of the EMG3 in the request 4 does not change, acquires corresponding data to be processed from the database according to the identification information of the request 4, processes the data to be processed, and stores the processing result in the database; the service thread 2 determines that the sequence number 1 of the EMG2 in the request 2 is not changed, acquires corresponding data to be processed from the database according to the identification information of the request 2, processes the data to be processed, and stores the processing result in the database; and the service thread 3 determines that the serial number 2 of the EMG1 in the request 3 is not changed, acquires corresponding data to be processed from the database according to the identification information of the request 3, processes the data to be processed, and stores the processing result in the database.
A method for processing a request according to another embodiment of the present invention is further described as follows:
it should be noted that the server has three service threads: service thread 1, service thread 2, and service thread 3.
Step 1, receiving a request 1 (product information is EMG5, store information is store B, warehouse information of stored product is warehouse a), a request 2 (product information is EMG5, store information is store B, warehouse information of stored product is warehouse a), a request 3 (product information is EMG6, store information is store B, warehouse information of stored product is warehouse a) and a request 4 (product information is EMG5, store information is store B, warehouse information of stored product is warehouse a).
And step 2, the service thread 1 encodes the EMG5 in the request 1, and the sequence number of the EMG5 in the request 1 is 1.
And step 3, the service thread 2 encodes the EMG5 in the request 2, and the sequence number of the EMG5 in the request 2 is 2.
And 4, the service thread 3 encodes the EMG6 in the request 3, and the sequence number of the EMG6 in the request 3 is 1.
And step 5, the service thread 1 determines that the request 1 and the request 2 are the same request according to the product information, the shop information and the warehouse information of the stored product in the request 1 and the request 2, the serial number 1 of the EMG5 in the request 1 is not equal to the serial number 2 of the EMG5 in the request 2, and the service thread 1 gives up the request 1.
And 6, the service thread 1 encodes the EMG5 in the request 4, and the sequence number of the EMG5 in the request 4 is 3.
Step 7, the service thread 2 determines that the request 2 and the request 4 are the same request according to the product information, the store information and the warehouse information of the stored product in the request 2 and the request 4, and the serial number 2 of the EMG5 in the request 2 is not equal to the serial number 3 of the EMG5 in the request 4. However, the time when the serial number 2 of the EMG5 in the verification request 2 is not equal to the serial number 3 of the EMG5 in the request 4 and the interval between the time when the stock quantity of the store B of the EMG5 is saved in the database last time are already longer than 30 seconds, the service thread 2 acquires corresponding data to be processed from the database according to the identification information of the request 2, processes the data to be processed and saves the processing result in the database.
In this step, the process of serial number verification by the service thread may be set before the ratio of the store inventory to the warehouse inventory and/or the warehouse inventory is obtained, or may be set before the processing result is saved in the database, so that the obtaining and saving resources may be reduced.
If the service thread 2 confirms that the time interval between the time stamps of the request 4 and the time stamp of the request 2 is greater than 30 seconds, the service thread 2 acquires corresponding to-be-processed data from the database according to the identification information of the request 2, processes the to-be-processed data, and stores the processing result in the database. It should be understood that, no matter at which interval the verification is performed, the problem that the user cannot obtain the processing result due to continuous abandoning of the request can be avoided, and the timeliness of the processing is ensured.
Step 8, the service thread 3 determines that the sequence number 1 of the EMG6 in the request 3 does not change, acquires corresponding data to be processed from the database according to the identification information of the request 3, processes the data to be processed, and stores the processing result in the database; the service thread 1 determines that the sequence number 3 of the EMG5 in the request 4 does not change, acquires corresponding data to be processed from the database according to the identification information of the request 4, processes the data to be processed, and stores the processing result in the database.
It should be noted that the core of the embodiment of the present invention is to calculate the store inventory of the product only once and abandon the repeated calculation when the store inventory of the product needs to be calculated many times at the same time or in a short time, thereby saving the resources consumed by the repeated calculation, the resources consumed by the repeated saving to the database, and the resources consumed by the repeated synchronization to other systems. In addition, the embodiment of the invention abandons repeated calculation, so that under the condition of high concurrency, compared with the prior art, more requests can be processed, the request processing speed is higher, the occurrence of the condition that calculation cannot be carried out is reduced, and the user experience degree is improved.
The method of processing a request is described above in connection with fig. 1-3, and the apparatus for processing a request is described below in connection with fig. 4.
In order to solve the problems in the prior art, an embodiment of the present invention provides an apparatus for processing a request, which may be disposed in a server, as shown in fig. 4, and includes:
a receiving unit 401, configured to receive a plurality of requests, where the requests include identification information.
A selecting unit 402, configured to screen out, from the plurality of requests, a request with the same identification information as the same request.
A processing unit 403, configured to obtain corresponding to-be-processed data from a database according to the identification information of the same request, process the to-be-processed data, store a processing result in the database, and discard part of the requests in the same request.
In this embodiment of the present invention, the processing unit 403 is specifically configured to:
sequentially arranging each request in the same request according to the time stamp;
reserving the request closest to the current timestamp, and giving up other requests;
and acquiring corresponding data to be processed from a database according to the identification information of the request closest to the current timestamp, processing the data to be processed, and storing a processing result in the database.
In this embodiment of the present invention, the processing unit 403 is further specifically configured to:
and before the request closest to the current timestamp is reserved and other requests are abandoned, if the interval of the timestamps of any adjacent requests is greater than a preset value, acquiring corresponding data to be processed from a database according to the identification information of one request in the adjacent requests, processing the data to be processed, and storing the processing result in the database.
In an embodiment of the present invention, the identification information includes product information, store information, and warehouse information that stores the product;
the selecting unit 402 is specifically configured to: after receiving a plurality of requests, screening out any different request of the product information, the shop information and the warehouse information for storing the product from the plurality of requests as different requests;
the processing unit 403 is further specifically configured to: and respectively acquiring corresponding data to be processed from a database according to the identification information of the different requests, processing the data to be processed, and storing a processing result in the database.
It should be understood that the functions performed by the components of the apparatus for processing a request according to the embodiments of the present invention have been described in detail in the method for processing a request according to the above embodiments, and are not described herein again.
Fig. 5 illustrates an exemplary system architecture 500 to which the method of processing a request or the apparatus for processing a request of an embodiment of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 501, 502, 503. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for processing the request provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the apparatus for processing the request is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a receiving unit, a selecting unit, and a processing unit. Where the names of the units do not in some cases constitute a limitation on the units themselves, for example, a receiving unit may also be described as a "unit that receives multiple requests, including identification information".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: receiving a plurality of requests, the requests including identification information; screening out the requests with the same identification information from the plurality of requests as the same requests; and acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and discarding part of requests in the same request.
According to the technical scheme of the embodiment of the invention, the same request is screened from a plurality of requests through the identification information, the corresponding data to be processed is obtained from the database according to the identification information of the same request, the data to be processed is processed, the processing result is stored in the database, and partial requests in the same request are abandoned, so that the resources consumed by repeated calculation are reduced in a mode of abandoning partial requests in the same request under the condition of ensuring the processing result. More requests can be processed under the high concurrency condition, and the request processing speed is higher, so that the processing performance is improved, a user can quickly obtain the processing result of the same request, the processing timeliness is ensured, and the user experience is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of processing a request, comprising:
receiving a plurality of requests, the requests including identification information;
screening out the requests with the same identification information from the plurality of requests as the same requests;
and acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and discarding part of requests in the same request.
2. The method of claim 1, wherein acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and discarding a part of requests in the same request comprises:
sequentially arranging each request in the same request according to the time stamp;
reserving the request closest to the current timestamp, and giving up other requests;
and acquiring corresponding data to be processed from a database according to the identification information of the request closest to the current timestamp, processing the data to be processed, and storing a processing result in the database.
3. The method of claim 2, further comprising, before reserving the request closest to the current timestamp and discarding other requests:
and if the interval of the time stamps of any adjacent request is larger than a preset value, acquiring corresponding data to be processed from a database according to the identification information of one request in the adjacent requests, processing the data to be processed, and storing a processing result in the database.
4. The method of claim 1, wherein the identification information includes product information, store information, and warehouse information in which the product is stored;
after receiving the plurality of requests, further comprising:
and screening out different requests of any one of the product information, the shop information and the warehouse information for storing the product from the requests to serve as different requests, respectively acquiring corresponding data to be processed from a database according to identification information of the different requests, processing the data to be processed, and storing a processing result in the database.
5. An apparatus for processing a request, comprising:
a receiving unit configured to receive a plurality of requests, the requests including identification information;
a selecting unit configured to screen out, from the plurality of requests, requests having the same identification information as a same request;
and the processing unit is used for acquiring corresponding data to be processed from a database according to the identification information of the same request, processing the data to be processed, storing a processing result in the database, and abandoning part of requests in the same request.
6. The apparatus according to claim 5, wherein the processing unit is specifically configured to:
sequentially arranging each request in the same request according to the time stamp;
reserving the request closest to the current timestamp, and giving up other requests;
and acquiring corresponding data to be processed from a database according to the identification information of the request closest to the current timestamp, processing the data to be processed, and storing a processing result in the database.
7. The apparatus according to claim 6, wherein the processing unit is further specifically configured to:
and before the request closest to the current timestamp is reserved and other requests are abandoned, if the interval of the timestamps of any adjacent requests is greater than a preset value, acquiring corresponding data to be processed from a database according to the identification information of one request in the adjacent requests, processing the data to be processed, and storing the processing result in the database.
8. The apparatus of claim 5, wherein the identification information includes product information, store information, and warehouse information in which the product is stored;
the selection unit is specifically configured to: after receiving a plurality of requests, screening out any different request of the product information, the shop information and the warehouse information for storing the product from the plurality of requests as different requests;
the processing unit is specifically further configured to: and respectively acquiring corresponding data to be processed from a database according to the identification information of the different requests, processing the data to be processed, and storing a processing result in the database.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201910887393.5A 2019-09-19 2019-09-19 Method and device for processing request Pending CN112527826A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910887393.5A CN112527826A (en) 2019-09-19 2019-09-19 Method and device for processing request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910887393.5A CN112527826A (en) 2019-09-19 2019-09-19 Method and device for processing request

Publications (1)

Publication Number Publication Date
CN112527826A true CN112527826A (en) 2021-03-19

Family

ID=74974229

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910887393.5A Pending CN112527826A (en) 2019-09-19 2019-09-19 Method and device for processing request

Country Status (1)

Country Link
CN (1) CN112527826A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101998682A (en) * 2009-08-27 2011-03-30 中兴通讯股份有限公司 Device and method for acquiring service content by personal network equipment and related device thereof
CN106357694A (en) * 2016-11-10 2017-01-25 天脉聚源(北京)传媒科技有限公司 Method and device for processing access request
CN107566516A (en) * 2017-09-25 2018-01-09 平安科技(深圳)有限公司 Concurrent amount control method, application server, system and storage medium
CN109040209A (en) * 2018-07-23 2018-12-18 深圳市牛鼎丰科技有限公司 Intercept method, apparatus, computer equipment and the storage medium of repetitive requests

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101998682A (en) * 2009-08-27 2011-03-30 中兴通讯股份有限公司 Device and method for acquiring service content by personal network equipment and related device thereof
CN106357694A (en) * 2016-11-10 2017-01-25 天脉聚源(北京)传媒科技有限公司 Method and device for processing access request
CN107566516A (en) * 2017-09-25 2018-01-09 平安科技(深圳)有限公司 Concurrent amount control method, application server, system and storage medium
CN109040209A (en) * 2018-07-23 2018-12-18 深圳市牛鼎丰科技有限公司 Intercept method, apparatus, computer equipment and the storage medium of repetitive requests

Similar Documents

Publication Publication Date Title
CN109376155B (en) ID generation method and device, storage medium and electronic device
CN108734559B (en) Order processing method and device
CN109428926B (en) Method and device for scheduling task nodes
CN107426336B (en) Method and device for adjusting push message opening rate
CN111062572B (en) Task allocation method and device
CN110738436A (en) method and device for determining available stock
CN108764866B (en) Method and equipment for allocating resources and drawing resources
CN108985805B (en) Method and device for selectively executing push task
CN113610448A (en) Article scheduling method and device, electronic equipment and computer readable medium
CN110928594A (en) Service development method and platform
CN113760982A (en) Data processing method and device
CN110321252B (en) Skill service resource scheduling method and device
CN108810130B (en) Method and device for planning distribution request
CN112667368A (en) Task data processing method and device
CN108683608B (en) Method and device for distributing flow
CN111177109A (en) Method and device for deleting overdue key
CN112527826A (en) Method and device for processing request
CN113127561B (en) Method and device for generating service single number, electronic equipment and storage medium
CN110378714B (en) Method and device for processing access data
CN109902847B (en) Method and device for predicting amount of orders in branch warehouse
CN111694670A (en) Resource allocation method, device, equipment and computer readable medium
CN113626175A (en) Data processing method and device
CN112784187A (en) Page display method and device
CN112667627B (en) Data processing method and device
CN116187987A (en) Digital currency transaction method and device

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