Summary of the invention
To solve the above-mentioned problems.The present invention provides a kind of data-updating method, device, storage medium and equipment.
A kind of data-updating method is provided according to the first aspect of the invention, comprising: is obtained headend equipment and is sent extremelyFew data update request;The data identified with identical data are updated into request storage and arrive queue;To the queueIn the data update request successively handled, the processing includes: to read the data more according to the Data IdentificationNewly request corresponding data to be updated;It updates and requests in response to the data, handle the data to be updated;It stores processedThe data to be updated to caching;And
Judge whether the time of the processing reaches predetermined period of time;If so, by described in the caching to moreNew data is updated into database, and suspends the processing until the operation that the data to be updated are updated to database is completed.
Further, after the data to be updated are updated to the database, Xiang Suoshu headend equipment sends data moreThe response message newly completed.
Further, the data in the queue are updated to request successively to carry out handling and further comprises, according to elder generationThe data for reading the queue into the sequence first gone out update request.
Further, according to the Data Identification, reading the corresponding data to be updated of the data update request includes:
Judge in the caching with the presence or absence of corresponding data to be updated;
If so, reading corresponding data to be updated from the caching;
If it is not, then reading corresponding data to be updated from the database.
According to the second aspect of the invention, a kind of data update apparatus is provided, module is obtained, for obtaining headend equipment hairAt least one data sent update request;Queue module is deposited for the data that there is identical data to identify to be updated requestStore up queue;Processing module is successively handled, the processing module for updating request to the data in the queueIt include: reading unit, for reading the data and updating the corresponding data to be updated of request according to the Data Identification;ProcessingUnit is requested for updating in response to the data, handles the data to be updated;Storage unit, it is processed for storingThe data to be updated to caching;And
Timing module, for judging whether the time of the processing reaches predetermined period of time;If so, by the cachingIn the data to be updated update into database, and suspend the processing until the data to be updated are updated to databaseOperation complete.
Further, after the data to be updated are updated to the database, Xiang Suoshu headend equipment sends data moreThe response message newly completed.
Further, the data in the queue are updated to request successively to carry out handling and further comprises, according to elder generationThe data for reading the queue into the sequence first gone out update request.
Further, which is characterized in that according to the Data Identification, it is corresponding to be updated to read the data update requestData include:
Judge in the caching with the presence or absence of corresponding data to be updated;
If so, reading corresponding data to be updated from the caching;
If it is not, then reading corresponding data to be updated from the database.
According to the third aspect of the invention we, a kind of non-volatile memory medium, the non-volatile memory medium are also providedWith the instruction being stored therein, when executed, so that the data that processor executes above-mentioned first aspect updateMethod.
According to the fourth aspect of the invention, a kind of equipment, including memory are also provided, the executable finger of computer is stored withIt enables, processor, the processor is configured to executing described instruction to implement the data-updating method of above-mentioned first aspect.
Compared with prior art, the main distinction and its effect are embodiment of the present invention:
The data-updating method of the embodiment of the present invention, it is not additional to database to deposit in service data updating processingStorage relies on, and reduces issued transaction delay and simplifies system complexity.In addition, the data-updating method of the embodiment of the present invention utilizesDatabase is written in more new data by delay, makes it possible to reduce the write-in number of database, and lifting system entirety carries energyPower.In addition, by successful according to database write-in as a result, end equipment sends response message forward, so that in burst delay machineUnder scene, the data in caching can lose.As long as the update operation completed before, data are all reliable.In addition, the data-updating method of the embodiment of the present invention can be completed in a process, distributed transaction is not needed, volume has been savedOuter maintenance cost and avoid consistency risk.
Specific embodiment
To keep purpose and the technical solution of the embodiment of the present invention clearer, below in conjunction with the attached of the embodiment of the present inventionFigure, is clearly and completely described the technical solution of the embodiment of the present invention.Obviously, described embodiment is of the inventionA part of the embodiment, instead of all the embodiments.Based on described the embodiment of the present invention, those of ordinary skill in the artEvery other embodiment obtained, shall fall within the protection scope of the present invention under the premise of being not necessarily to creative work.
Embodiment there is provided a kind of embodiments of data-updating method according to the present invention, it should be noted that attachedThe step of process of figure illustrates can execute in a computer system such as a set of computer executable instructions, though also,So logical order is shown in flow charts, but in some cases, it can be to be different from shown by sequence execution hereinOr the step of description.
Method implementation provided by the application mode can be held in mobile terminal, terminal or serverRow.For running on computer terminals, Fig. 1 is the terminal of the data-updating method of embodiment according to the present inventionHardware block diagram.As shown in Figure 1, terminal 100 may include one or more (only showing one in figure) processingDevice 101 (processor 101 can include but is not limited to central processor CPU, image processor GPU, digital signal processor DSP,The processing unit of Micro-processor MCV or programmable logic device FPGA etc.), the input/output interface 102 for being interacted with user,Memory 103 for storing data and the transmitting device 104 for communication function.Those of ordinary skill in the art can be withUnderstand, structure shown in FIG. 1 is only to illustrate, and does not cause to limit to the structure of above-mentioned electronic device.For example, terminal100 may also include than shown in Fig. 1 more perhaps less component or with the configuration different from shown in Fig. 1.
Memory 103 can be used for storing data library, queue, application software software program and module, such as present invention is realCorresponding program instruction/the module of data-updating method in mode is applied, processor 101 is stored in memory 103 by operationSoftware program and module realize above-mentioned data-updating method thereby executing various function application and data processing.Memory 103 may include high speed random access memory, may also include nonvolatile memory, as one or more magnetic storage fillsIt sets, flash memory or other non-volatile solid state memories.In some instances, memory 103 can further comprise relative to placeThe remotely located memory of device 101 is managed, these remote memories can pass through network connection to terminal 100.Above-mentioned netThe example of network includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Transmitting device 104 is used to that data to be received or sent via network, and network may include various connection types, such asWired, wireless communication link or fiber optic cables etc..Above-mentioned network specific example may include the communication of terminal 100The internet that supplier provides.
Under above-mentioned running environment, the present invention provides data-updating methods as shown in Figure 2.This method can be appliedIn server, executed by the processor in server.At least one application program, embodiment party of the present invention are installed in serverThe type of formula not defining application, can be system class application program, or software class application program.
Fig. 2 shows the flow charts of data-updating method 200 according to an embodiment of the present invention.As shown in Fig. 2, this method hasBody process flow is as described below.
S210, at least one data update request that headend equipment is sent is obtained.
In an embodiment of the present invention, headend equipment includes but is not limited to smart phone, tablet computer, computer, front endEquipment is responsible for sending data update request to server.Data update request include Data Identification, the Data Identification be database,Caching and queue in data unique identification, for example, in database affairs key assignments.As an example, data update requestIt can be by the way that such as, network receives the data reception module of server or function call etc. to obtain.
S220, the data identified with identical data are updated to request storage to queue.
It is appreciated that queue is a kind of structure for storing data, for example, storehouse, list, Hash table etc..This stepIn, queue is used to store the data with identical data mark and updates request.Queue, which can be, pre-establishes and resides caching,It is also possible to obtain when data update request and establishes, which is not limited by the present invention.It, can be for not at the same time it can also understandSame Data Identification, establishes corresponding queue, and multiple and different queues can concurrently carry out following retouch independently of each otherThe various processing stated.
In concurrent scene, queue, which can continue storing data update, is requested, the maximum memory space until reaching queue,The memory space can determine that the present invention is without limitation according to hardware performance.
S230, the data in queue are updated and request successively to handle.
As an example, in the high concurrent scene of temporal sensitivity, queue can be used first in first out (FIFO,First-in, first-out) method, according to data update request request time sequencing, by data update requestStorage in the queue, the request time of the request of queue bottom than the request at top request time earlier.In this way, in queue mostEarly request is handled at first, then reprocesses next earliest request, sends data according to headend equipment to ensure thatThe sequence for updating request successively handles these requests.As another example, in the concurrent field unrelated with the time sequencing of requestQueuing is seized in Jing Zhong, the technology realization that such as mutual exclusion lock (Mutual exclusion, be abbreviated as Mutex) can be used, so thatEach request is to be lined up successively to be handled.The processing is detailed below.
S231, according to Data Identification, read data and update and request corresponding data to be updated.
In order to reduce delay in concurrent scene, needs in the buffer to update data and request to handle.Specifically,When starting to process data update request, to judge that the data update and request whether the corresponding data to be updated have stored inIn caching, the general Data Identification by request searches whether the data for having with like-identified in the buffer, if cachingIn stored the data to be updated, as long as then reading these data from caching;If there is no number to be updated in cachingAccording to then then needing to read data to be updated to slow from database or other storage mediums via bus or network by interfaceIn depositing, to carry out subsequent processing;If creation corresponds in the database also without corresponding data to be updated in databaseTarget object after, in the caching that is read;Or target object is directly created in the buffer.
As another example, the data of data to be updated can update in initial data and request to be stored in queueMeanwhile it concurrently being read in caching from database or other storage mediums.It, can be further in this way under high concurrent sceneImprove request processing speed in ground.
S232, it updates and requests in response to data, handle data to be updated.
Request is updated according to data, and corresponding data processing operation is executed to the data to be updated of reading.Illustratively, numberInclude according to processing operation hand over various easy arbitrary process, for example, on the increase and decrease of fund and inventory or the line of commodity the second kill, graspIt can also be the modification etc. of object properties.
S233, the processed data to be updated of storage to caching.
It is appreciated that caching can be common memory, but according to the design of server architecture, it is also possible to external slowIt deposits, such as the databases such as Redis, Mongo.When the subsequent request in queue starts to process, it is only necessary to read previous in cachingRequest treated data to be updated.In this way, not needing reading database, data can give the request of next same key assignmentsIt uses, data is directly obtained from caching, speed is faster;It can guarantee the serial of data manipulation again.
According to an embodiment of the invention, can change or return corresponding data more after data storage to caching to be updatedThe state newly requested shows that the business operation of the request has been completed.Later, the notification queue data have updated the business of requestThrough completing, the subsequent request in queue can be started to process, or be also possible to discharge mutual exclusion lock.Optionally, in some logarithmsIn scene relatively low according to security requirement but more demanding to process performance, at this time can further to the data moreThe response message for newly requesting corresponding headend equipment returned data to be updated successfully.It can be further improved 50% performance in this way.
S240, judge whether the time of processing reaches predetermined period of time.
Data in caching are not due to having persistence, and there are the risks of loss.Therefore the number according to concurrent request is neededAmount, presets the time cycle, periodically by the data to be updated write-in database in caching, completes data and updates.
As an example, can first or initial data in the queue when updating request and starting processed, openThe timed tasks such as dynamic timer thread, when timer reaches predetermined period of time, by interface by the number to be updated in cachingAccording to write-in database or other storage mediums, to complete the persistence of data.In general, in high concurrent, week predetermined timePhase is Microsecond grade.In order to guarantee the consistency of data manipulation, during database is written in data to be updated, can suspend pairThe subsequent processing for updating request continues to execute the processing updated to data after the completion of the write-in of pending data library in queue.It is general nextIt says, in atomic operation magnitude, the duration that database write operation is spent is significantly larger than the handling duration of a request, therefore notIt will appear data collision or inconsistent situation.
Optionally, complete in predetermined period processing data update request can cache in waited, wait until to moreNew data is updated to after database, then the corresponding all headend equipments batch of data update request of processing are completed into predetermined periodAmount ground sends data and updates the response message completed.In this way, burst delay machine scene in, due to data do not have persistence itIt is preceding that there is no the message that is updated successfully of headend equipment data is informed, then the data in caching can lose, as long as and itThe preceding update operation completed, surface data has persisted, then data are all reliable.
Hereafter, terminate this process.
In actual test, for the prior art, a key assignments is updated by normal mode, read from caching every time andModification, database is arrived in storage at once after modification.The results of property of test: 300 processing capacities per second.Main time-consuming is at queuingReason, the write-in expense of network overhead and database share 300 database update operations for 1 second one.
According to an embodiment of the invention, a key assignments is updated by mode of the invention, the performance of test: local to callIt can achieve 9000 processing capacities per second, than 30 times of Normal practice performance.For the set time period of 50ms, do within 1 second20 database update operations, the quantity of database manipulation reduce 93%.
In conclusion data-updating method provided in this embodiment does not have database in service data updating processingAdditional storage relies on, and reduces issued transaction delay and simplifies system complexity.In addition, the data of the embodiment of the present invention updateUsing delay database is written in more new data by method, makes it possible to reduce the write-in number of database, lifting system entiretyIt can bearing capacity.In addition, by successful according to database write-in as a result, end equipment sends response message forward, so that prominentUnder the scene for sending out delay machine, the data in caching can lose.As long as the update operation completed, data are all beforeReliably.In addition, the data-updating method of the embodiment of the present invention can be completed in a process, distributed transaction is not needed,It has saved additional maintenance cost and has avoided consistency risk.
Each method embodiment of the invention can be realized in a manner of software, magnetic part, firmware etc..Regardless of the present invention be withSoftware, magnetic part or firmware mode realize that instruction code may be stored in any kind of computer-accessible memoryIn (such as permanent perhaps revisable volatibility is perhaps non-volatile solid or non-solid, it is fixed orThe replaceable medium etc. of person).Equally, memory may, for example, be programmable logic array (Programmable ArrayLogic, referred to as " PAL "), random access memory (Random Access Memory, referred to as " RAM "), it may be programmed read-only depositReservoir (Programmable Read Only Memory, referred to as " PROM "), read-only memory (Read-Only Memory, letterClaim " ROM "), electrically erasable programmable read-only memory (Electrically Erasable Programmable ROM, referred to as" EEPROM "), disk, CD, digital versatile disc (Digital Versatile Disc, referred to as " DVD ") etc..
Fig. 3 is the schematic block diagram of data update apparatus 300 according to an embodiment of the present invention.The device is above-mentioned for executingMethod flow, comprising:
Module 310 is obtained, at least one data for obtaining headend equipment transmission update request;
Queue module 320, the data for that will have identical data to identify update request storage to queue;
Processing module 330 is successively handled for updating request to the data in queue, and processing module includes:
Reading unit 331, for reading data and updating the corresponding data to be updated of request according to Data Identification;
Processing unit 332 requests for updating in response to data, handles data to be updated;
Storage unit 333, for storing processed data to be updated to caching;And
Timing module 340, for judging whether the time of processing reaches predetermined period of time;
If so, by caching data to be updated update into database, and suspend processing until data to be updated moreThe new operation to database is completed.
In one example, after data to be updated are updated to database, end equipment sends data and updates the sound completed forwardAnswer message.
In one example, the data in queue are updated to request successively to carry out handling and further comprises, according to first in first outSequence read queue data update request.
In one example, according to Data Identification, reading the corresponding data to be updated of data update request includes:
It whether there is corresponding data to be updated in judgement caching;
If so, reading corresponding data to be updated from caching;
If it is not, then reading corresponding data to be updated from database.
It should be noted that data update apparatus 300 can be configured as execute corresponding operation in method 200,Movement and process are omitted herein to these operations, movement and the description of process.
In conclusion data update apparatus provided in this embodiment does not have database in service data updating processingAdditional storage relies on, and reduces issued transaction delay and simplifies system complexity.In addition, the data of the embodiment of the present invention updateUsing delay database is written in more new data by method, makes it possible to reduce the write-in number of database, lifting system entiretyIt can bearing capacity.In addition, by successful according to database write-in as a result, end equipment sends response message forward, so that prominentUnder the scene for sending out delay machine, the data in caching can lose.As long as the update operation completed, data are all beforeReliably.In addition, the data-updating method of the embodiment of the present invention can be completed in a process, distributed transaction is not needed,It has saved additional maintenance cost and has avoided consistency risk.
According to another embodiment of the present invention, a kind of non-volatile memory medium is also provided, the non-volatile memory mediumWith the instruction being stored therein, when the instruction is performed, so that processor executes data-updating method, comprising:
It obtains at least one data that headend equipment is sent and updates request;
The data identified with identical data are updated into request storage and arrive queue;
It updates request to the data in queue successively to handle, processing includes:
According to Data Identification, reads data and update the corresponding data to be updated of request;
It updates and requests in response to data, handle data to be updated;
Processed data to be updated are stored to caching;And
Judge whether the time of processing reaches predetermined period of time;
If so, by caching data to be updated update into database, and suspend processing until data to be updated moreThe new operation to database is completed.
Further, after data to be updated are updated to database, end equipment sends data and updates the response completed forwardMessage.
Further, the data in queue are updated to request successively to carry out handling and further comprises, according to first in first outThe data that sequence reads queue update request.
Further, according to Data Identification, reading the corresponding data to be updated of data update request includes:
It whether there is corresponding data to be updated in judgement caching;
If so, reading corresponding data to be updated from caching;
If it is not, then reading corresponding data to be updated from database.
Further, according to another embodiment of the present invention, a kind of equipment, including memory are also provided, calculating is stored withMachine executable instruction, processor, processor are configured as executing instruction to implement the process of data update, comprising:
It obtains at least one data that headend equipment is sent and updates request;
The data identified with identical data are updated into request storage and arrive queue;
It updates request to the data in queue successively to handle, processing includes:
According to Data Identification, reads data and update the corresponding data to be updated of request;
It updates and requests in response to data, handle data to be updated;
Processed data to be updated are stored to caching;And
Judge whether the time of processing reaches predetermined period of time;
If so, by caching data to be updated update into database, and suspend processing until data to be updated moreThe new operation to database is completed.
Further, after data to be updated are updated to database, end equipment sends data and updates the response completed forwardMessage.
Further, the data in queue are updated to request successively to carry out handling and further comprises, according to first in first outThe data that sequence reads queue update request.
Further, according to Data Identification, reading the corresponding data to be updated of data update request includes:
It whether there is corresponding data to be updated in judgement caching;
If so, reading corresponding data to be updated from caching;
If it is not, then reading corresponding data to be updated from database.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that implementation of the inventionExample can be practiced without these specific details.In some instances, well known method, structure is not been shown in detailAnd technology, so as not to obscure the understanding of this specification.
Similarly, it should be understood that in order to simplify the present invention and help to understand one or more of the various inventive aspects,Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimesIn example, figure or descriptions thereof.However, the disclosed method should not be interpreted as reflecting the following intention: i.e. required to protectShield the present invention claims features more more than feature expressly recited in each claim.More precisely, such as rightAs claim reflects, inventive aspect is all features less than single embodiment disclosed above.Therefore, it then follows toolThus claims of body embodiment are expressly incorporated in the specific embodiment, wherein each claim conduct itselfSeparate embodiments of the invention.
Those skilled in the art will understand that can be carried out adaptively to the module in the equipment in embodimentChange and they are arranged in one or more devices different from this embodiment.It can be the module or list in embodimentMember or component are combined into a module or unit or component, and furthermore they can be divided into multiple submodule or subelement orSub-component.Other than such feature and/or at least some of process or unit exclude each other, it can use anyCombination is to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so disclosedAll process or units of what method or apparatus are combined.Unless expressly stated otherwise, this specification is (including adjoint powerBenefit requires, abstract and attached drawing) disclosed in each feature can be by providing identical, equivalent, or similar purpose alternative features come generationIt replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodimentsIn included certain features rather than other feature, but the combination of the feature of different embodiments mean it is of the inventionWithin the scope of and form different embodiments.For example, in detail in the claims, embodiment claimed it is one of anyCan in any combination mode come using.
Word "comprising" does not exclude the presence of element or step not listed in the claims.Word located in front of the element"a" or "an" does not exclude the presence of multiple such elements.The present invention can by means of include several different elements hardwareAnd it is realized by means of properly programmed terminal device.In the unit claim for listing several terminal devices, theseSeveral in terminal device, which can be, to be embodied by the same item of hardware.Word first, second, and thirdUsing not indicating any sequence.These words can be construed to title.