Summary of the invention
In view of this, this specification embodiment provides a kind of method of data synchronization and device, calculates equipment and storage is situated between
Matter, to solve technological deficiency existing in the prior art.
According to this specification embodiment in a first aspect, a kind of method of data synchronization is provided, applied to client, packet
It includes:
Exam software is logged in, sends data synchronization request to database, and receive the first versions of data of database transmission
Number;
When the versions of data No. the second and the first data version number that determine client are inconsistent, the data are received
The data information and the database updated in library relative to the versions of data No. second sends the updated after data information
Versions of data No. three;
Versions of data No. second of the client is updated to third versions of data number.
Optionally, further includes:
The answer data for obtaining candidate send synchronization request to server-side, carry the answer in the synchronization request
Data;
The synchronization request for carrying the answer data is sent to database by server-side, and receives the database hair
The third versions of data number sent;
When the versions of data number for determining client is consistent with the third version number, the answer data are uploaded to institute
Database is stated, and receives the versions of data No. the 4th that the database root is updated according to the answer data;
The versions of data number of the client is updated to versions of data No. the 4th.
Optionally, further includes:
When the versions of data number and the third versions of data number that determine client are inconsistent, receive in the database
The data information and the database that versions of data number relative to the client updates send the updated after data information
Versions of data No. five;
The versions of data number of the client is updated to versions of data No. the 5th;
The answer data are uploaded to the database, and receive what the database root was updated according to the answer data
Versions of data No. 6th;
Versions of data No. 5th of the client is updated to versions of data No. the 6th.
Optionally, described to receive the data packets updated in the database relative to the versions of data No. second
It includes:
Receive the structured data information of paper to be set the exam;
The first examination question data of paper are obtained according to the structured data information, cache the first examination question data and basis
Preset exhibition strategy shows the first examination question data.
Optionally, the answer data are uploaded to the database includes:
The answer data of acquisition candidate and the answer progress msg, answer data are cached;
The second examination question data are requested to server according to the answer progress msg and structured data information, receives and caches
The second examination question data;
The second examination question data are shown according to preset exhibition strategy, are received the answer data of candidate and are cached;
Server is uploaded in a manner of incremental transmission according to the answer data that preset upload strategy will be cached.
Optionally, the preset upload strategy includes:
The answer data for setting number road examination question are uploaded in batches or carry out answer data in batches according to setting byte number
It uploads or uploads answer data in batches according to the examination question page number.
According to the second aspect of this specification embodiment, a kind of data synchronization unit is provided, is configured in client, is wrapped
It includes:
Request module: being configured as logging in exam software, sends data synchronization request to database, and receives database hair
The first data version number sent;
Determining module: it is configured as when the versions of data No. the second and the first data version number that determine client are different
When cause, receives the data information updated in the database relative to the versions of data No. second and the database sends number
It is believed that the third versions of data number updated after breath;
Update module: it is configured as versions of data No. the second of the client being updated to third versions of data number.
Optionally, further includes:
Request module is additionally configured to obtain the answer data of candidate, sends synchronization request, the synchronization to server-side
The answer data are carried in request;
First receiving module: it is configured as asking by server-side to the synchronization that database transmission carries the answer data
It asks, and receives the third versions of data number that the database is sent;
Determining module is additionally configured to when the versions of data number for determining the client is consistent with the third version number,
The answer data are uploaded to the database, and receive the 4th data that the database root is updated according to the answer data
Version number;
Update module is additionally configured to the versions of data number of the client being updated to versions of data No. the 4th.
Optionally, further includes:
Determining module is additionally configured to work as the versions of data number for determining the client and the third versions of data number not
When consistent, the data information and the database updated in the database relative to the versions of data number of the client is received
Send the versions of data No. the 5th updated after data information;
Update module is additionally configured to the versions of data number of the client being updated to versions of data No. the 5th;
Second receiving module: it is configured as the answer data being uploaded to the database, and receives the database
The versions of data No. the 6th updated according to the answer data;
Update module is additionally configured to versions of data No. the 5th of the client being updated to versions of data No. the 6th.
Optionally, the determining module includes:
First receiving unit: it is configured as receiving the structured data information of paper to be set the exam;
Display unit: it is configured as obtaining the first examination question data of paper according to the structured data information, described in caching
First examination question data simultaneously show the first examination question data according to preset exhibition strategy.
Optionally, the determining module includes:
Acquiring unit: be configured as obtain candidate answer data and the answer progress msg, by answer data into
Row caching;
The acquiring unit is additionally configured to be requested according to the answer progress msg and structured data information to server
Second examination question data receive and cache the second examination question data;
The display unit is additionally configured to show the second examination question data according to the preset exhibition strategy, receives
The answer data of candidate simultaneously cache;
Uploading unit: it is configured as uploading the tactful answer data that will be cached in a manner of incremental transmission according to preset
It is uploaded to server.
Optionally, the preset upload strategy includes:
The answer data for setting number road examination question are uploaded in batches or carry out answer data in batches according to setting byte number
It uploads or uploads answer data in batches according to the examination question page number.
According to the third aspect of this specification embodiment, a kind of calculating equipment is provided, including memory, processor and deposit
The computer instruction that can be run on a memory and on a processor is stored up, the processor realizes the number when executing described instruction
The step of according to synchronous method.
According to the fourth aspect of this specification embodiment, a kind of computer readable storage medium is provided, is stored with meter
The step of calculation machine instruction, which realizes the method for data synchronization when being executed by processor.
In this specification embodiment, by logging in exam software, data synchronization request is sent to database, and receive data
The first data version number that library is sent, when the versions of data No. the second and the first data version number that determine client are inconsistent
When, it receives the data information updated in the database relative to the versions of data No. second and the database sends data
Versions of data No. second of the client is updated to third versions of data number by the third versions of data number updated after information,
It is uploaded to server in a manner of incremental transmission according to the answer data that preset upload strategy will be cached, passes through this specification
Method of data synchronization, can be to the data information in data synchronization process, kept in the data information and database of client
Unanimously, when client submits answer data, database receives answer data, guarantees that answer data are not lost, determines answer data
Integrality, largely shorten candidate and wait request time, while being carried out by incremental transmission data information mode
Transmitting data information accelerates the corresponding of exam software.
Specific embodiment
Many details are explained in the following description in order to fully understand the application.But the application can be with
Much it is different from other way described herein to implement, those skilled in the art can be without prejudice to the application intension the case where
Under do similar popularization, therefore the application is not limited by following public specific implementation.
Fig. 1 is to show the structural block diagram of the calculating equipment 100 according to one embodiment of this specification.The calculating equipment 100
Component include but is not limited to memory 110 and processor 120.Processor 120 is connected with memory 110 by bus 130,
Database 150 is for saving data.
Calculating equipment 100 further includes access device 140, access device 140 enable calculate equipment 100 via one or
Multiple networks 160 communicate.The example of these networks includes public switched telephone network (PSTN), local area network (LAN), wide area network
(WAN), the combination of the communication network of personal area network (PAN) or such as internet.Access device 140 may include wired or wireless
One or more of any kind of network interface (for example, network interface card (NIC)), such as IEEE802.11 wireless local area
Net (WLAN) wireless interface, worldwide interoperability for microwave accesses (Wi-MAX) interface, Ethernet interface, universal serial bus (USB) connect
Mouth, cellular network interface, blue tooth interface, near-field communication (NFC) interface, etc..
In one embodiment of this specification, unshowned other component in above-mentioned and Fig. 1 of equipment 100 is calculated
It can be connected to each other, such as pass through bus.It should be appreciated that calculating device structure block diagram shown in FIG. 1 is merely for the sake of example
Purpose, rather than the limitation to this specification range.Those skilled in the art can according to need, and increase or replace other portions
Part.
Calculating equipment 100 can be any kind of static or mobile computing device, including mobile computer or mobile meter
Calculate equipment (for example, tablet computer, personal digital assistant, laptop computer, notebook computer, net book etc.), movement
Phone (for example, smart phone), wearable calculating equipment (for example, smartwatch, intelligent glasses etc.) or other kinds of shifting
Dynamic equipment, or the static calculating equipment of such as desktop computer or PC.Calculating equipment 100 can also be mobile or state type
Server.
Wherein, processor 120 can execute the step in method of data synchronization shown in Fig. 2.Fig. 2 is shown according to this theory
The flow chart of the method for data synchronization of bright one embodiment of book, including step 202 is to step 206.
Step 202: logging in exam software, send data synchronization request to database, and receive the first of database transmission
Versions of data number.
Exam software is first logged by candidate, the data information in the non-sync database of client passes through client
Synchronization request is sent to database, and obtains the first data version number of database, by sending synchronization request, determines client
The data information needed.
Step 204: when the versions of data No. the second and the first data version number that determine client are inconsistent, receiving
After the data information and database transmission data information that are updated in the database relative to the versions of data No. second
The third versions of data number of update.
For example, candidate carries out maths exam by software, and candidate, which first enters, to be examined in one embodiment of this specification
Software is tried, needs to obtain data information, first data version number is not in the versions of data No. the second and database of active client
Unanimously, determining that data information does not synchronize, client receives the data information and the versions of data according to database update,
Current data version number is updated.
Inconsistent by comparing the second versions of data and the first data version number of client, database is to client
Data information is sent, database is simultaneously updated first data version number according to the data information of transmission, determines the third updated
Versions of data number is simultaneously sent to client.
Step 206: versions of data No. the second of the client is updated to third versions of data number.
By the way that versions of data No. the second of client is updated to third versions of data number, the data letter in database is determined
Breath is updated to client, and current client data information and date library data information is synchronous.
It is described to receive in the database relative to the versions of data No. second update in one embodiment of this specification
Data information includes:
Receive the structured data information of paper to be set the exam;
The first examination question data of paper are obtained according to the structured data information, cache the first examination question data and basis
Preset exhibition strategy shows the first examination question data.
In one embodiment of this specification, further includes:
The answer data for obtaining candidate send synchronization request to server-side, carry the answer in the synchronization request
Data;
The synchronization request for carrying the answer data is sent to database by server-side, and receives the database hair
The third versions of data number sent;
When the versions of data number for determining client is consistent with the third version number, the answer data are uploaded to institute
Database is stated, and receives the versions of data No. the 4th that the database root is updated according to the answer data;
The versions of data number of the client is updated to versions of data No. the 4th.
In one embodiment of this specification, further includes:
When the versions of data number and the third versions of data number that determine the client are inconsistent, the data are received
It is updated after the data information and database transmission data information that are updated in library relative to the versions of data number of the client
Versions of data No. the 5th;
The versions of data number of the client is updated to versions of data No. the 5th;
The answer data are uploaded to the database, and receive what the database root was updated according to the answer data
Versions of data No. 6th;
Versions of data No. 5th of the client is updated to versions of data No. the 6th.
For example, candidate takes an exam in one embodiment of this specification, carry out submitting answer data, by judging
Whether the case where stating the versions of data number and the third versions of data of client, be determined current client data information
For newest data information.
When the versions of data number of client and the third versions of data number are consistent, the data information of client is newest
Data information, submit answer data, the answer data are received by database, are updated relative to the answer data
Versions of data number, generate newest versions of data No. 5th and be simultaneously sent to client, and more by the versions of data number of client
Newly it is versions of data No. the 5th, determines answer data to be committed to database, and client data information and database data are believed
Breath synchronizes.
When the versions of data number of the client and the third versions of data number are inconsistent, the data of active client
Information is not synchronized with database also, and database sends data information to client, and database is simultaneously believed according to the data of transmission
Breath is updated versions of data number, determines the third versions of data number updated and is sent to client, determines active client number
It is believed that breath is latest data information, then carries out submitting answer data, the answer data are received by database, are updated phase
It for the versions of data number of the answer data, generates newest versions of data No. 6th and is simultaneously sent to client, and by client
The versions of data number at end is updated to this number of sixth version, determines answer data to be committed to database, and client data information with
Database data synchronizing information.
In one embodiment of this specification, the answer data, which are uploaded to the database, includes:
The answer data of acquisition candidate and the answer progress msg, answer data are cached;
The second examination question data are requested to server according to the answer progress msg and structured data information, receives and caches
The second examination question data;
The second examination question data are shown according to preset exhibition strategy, are received the answer data of candidate and are cached;
Server is uploaded in a manner of incremental transmission according to the answer data that preset upload strategy will be cached.
In one embodiment of this specification, the structured data information includes:
According to the structured data information of topic serial number division or according to the structured data information of page number division or according to topic type
The structured data information of division.
In one embodiment of this specification, the first examination question data include:
The whole examination questions or paper to be set the exam of a kind of topic type of one of examination question or paper to be set the exam of the paper to be set the exam
One page examination question.
In one embodiment of this specification, the preset exhibition strategy includes:
From the examination question data cached extract setting number problem to candidate show or by paging show in a manner of to
Candidate shows.
In one embodiment of this specification, the answer progress msg obtains in the following manner:
The answer progress msg is currently answered by the current answer position of acquisition the first examination question data according to described
It inscribes ratio of the position in the first examination question data and obtains the answer progress msg.
In one embodiment of this specification, it is described by answer data carry out caching include:
Answer data are cached with the incidence relation of corresponding examination question topic according to answer data.
It is described to be requested according to the answer progress msg and structured data information to server in one embodiment of this specification
Second examination question data include:
Judge whether the corresponding ratio of answer progress msg of the first examination question data reaches the threshold value of setting;
When judging result is the threshold value for reaching setting, the first examination question data described in the structured data information are obtained
The information of next examination question data;
The second examination question data are requested to the server according to the information of next examination question data.
In one embodiment of this specification, further includes:
Click in the page page up or when lower one page button when receiving candidate, according to the answer data cached with it is right
It answers the incidence relation of examination question to load and shows the examination question data and answer data of corresponding page.
In one embodiment of this specification, further includes:
When detecting that candidate re-enters the answer data of current page, according to the modification of current page or newly-increased
Answer data and corresponding examination question serial number are updated the answer data cached.
In one embodiment of this specification, described when detecting that candidate re-enters the answer data of current page,
The answer data cached are updated according to the modification of current page or newly-increased answer data and corresponding examination question serial number
Later further include:
If caching answer data where the modification of current page or newly-increased answer data and corresponding examination question serial number it
It is preceding to be uploaded to the server, then only the modification of current page or newly-increased answer data and corresponding examination question serial number are uploaded
To the server.
In one embodiment of this specification, the preset upload strategy includes:
The answer data for setting number road examination question are uploaded in batches or carry out answer data in batches according to setting byte number
It uploads or uploads answer data in batches according to the examination question page number.
In this specification embodiment, by logging in exam software, data synchronization request is sent to database, and receive data
The first data version number that library is sent, when the versions of data No. the second and the first data version number that determine client are inconsistent
When, it receives the data information updated in the database relative to the versions of data No. second and the database sends data
Versions of data No. second of the client is updated to third versions of data number by the third versions of data number updated after information,
Server is uploaded in a manner of incremental transmission according to the answer data that preset upload strategy will be cached.
It, can be to the data information in data synchronization process, keeping client by the method for data synchronization of this specification
Consistent with the data information in database, when client submits answer data, database receives answer data, guarantees answer data
It does not lose, determines the integrality of answer data, candidate waits largely to be shortened on request time, while passing through increasing
Amount transmitting data information mode carries out transmitting data information, accelerates the corresponding of exam software, avoids synchronization a large number of users
It submits paper to cause the excessively high situation of server load, improves the stability of online testing software on the whole.
Fig. 3 is to show the flow chart of the method for data synchronization according to one embodiment of this specification, the method for data synchronization
It is described by taking maths exam as an example, which includes:
Step 302: obtaining the first data version number of database.
Exam software is first logged by candidate, the data information in the non-sync database of client passes through client
Synchronization request is sent to database, and obtains the first data version number of database, by sending synchronization request, determines client
The data information needed.
Step 304: judging whether first data version number is consistent with client data version number.
By the way that the first data version number is compared with client data version number, determine when number clients it is believed that
It whether synchronous with the data information of database ceases.
Step 306: obtaining newest data information.
Inconsistent by comparing the first data version number and client data version number, database sends out data information
It send to client, and by filtering out the already existing data information of client, improves the transmission rate of data information.
Step 308: update data of database version number.
For example, candidate carries out maths exam by software, and candidate, which first enters, to be examined in one embodiment of this specification
Software is tried, needs to obtain data information, first data version number is not in the versions of data No. the second and database of active client
Unanimously, determining that data information does not synchronize, client receives the data information and the versions of data according to database update,
Current data version number is updated.
Inconsistent by comparing the second versions of data and the first data version number of client, database is to client
Data information is sent, database is simultaneously updated first data version number according to the data information of transmission, determines the third updated
Versions of data number is simultaneously sent to client.
Step 310: client receives the data information and updates versions of data number.
The method provided through this embodiment synchronizes database data information with client data information, reduces
Database sends data information amount, improves the integrality of client synchronization data information, and keep client data information
Timing synchronization is kept with database data information.
Fig. 4 is to show the flow chart of the method for data synchronization according to one embodiment of this specification, the method for data synchronization
It is described by taking maths exam as an example, which includes:
Step 402: determining client data version number.
Step 404: judging whether versions of data number is consistent.
By judging whether client data version number is consistent with database data version number.
For example, candidate takes an exam in one embodiment of this specification, carry out submitting answer data, by judging
The case where stating the versions of data number and the versions of data of the database of client, is determined current client data information
It whether is newest data information.
When the versions of data number of the client is consistent with the versions of data number of the database, the data of client are believed
Breath is newest data information, submits answer data.
Step 406: database updates versions of data number relative to the answer data.
For example, candidate takes an exam in one embodiment of this specification, carry out submitting answer data, by judging
The case where stating the versions of data number and the versions of data of the database of client, is determined current client data information
It whether is newest data information.
The answer data are received by database, are updated the versions of data number relative to the answer data, it is raw
At newest versions of data number and it is sent to client, and the versions of data number of client is updated to newest versions of data
Number, answer data are determined to be committed to database, and client data information and database data synchronizing information.
Step 408: when client data version number and the database data version number are inconsistent, updating client data
Information.
When the versions of data number of the client and the third versions of data number are inconsistent, the data of active client
Information is not synchronized with database also, and database sends data information to client, and database is simultaneously believed according to the data of transmission
Breath is updated versions of data number, determines the versions of data number of the database updated and is sent to client, determines existing customer
End data information is latest data information, then carries out submitting answer data, receives the answer data by database, carries out more
Cenotype generates the versions of data number of newest database and is sent to client for the versions of data number of the answer data,
And the versions of data number of client is updated to the versions of data number of database, determine answer data to be committed to database, and
Client data information and database data synchronizing information.
Step 410: customer in response end.
Data information and answer data are synchronized by customer in response end.
The data information of client and database is synchronized, client is mentioned by the method provided through this embodiment
The answer data of friendship are synchronized to database.
Method of data synchronization through this embodiment, can be to the data information in data synchronization process, keeping client
Consistent with the data information in database, when client submits answer data, database receives answer data, guarantees answer data
It does not lose, determines the integrality of answer data, candidate waits largely to be shortened on request time, while passing through increasing
Amount transmitting data information mode carries out transmitting data information, accelerates the corresponding of exam software, avoids synchronization a large number of users
It submits paper to cause the excessively high situation of server load, improves the stability of online testing software on the whole.
Corresponding with above method embodiment, this specification additionally provides data synchronization unit embodiment, and figure: 5 show
This illustrates the module map of the data synchronization unit of an embodiment.As shown in figure 5, the device 500 includes:
Request module 502: being configured as logging in exam software, sends data synchronization request to database, and receive data
The first data version number that library is sent;
Determining module 504: it is configured as when the versions of data No. the second and the first data version number for determining client
When inconsistent, the data information updated in the database relative to the versions of data No. second and database hair are received
Send the third versions of data number updated after data information;
Update module 506: it is configured as versions of data No. the second of the client being updated to third versions of data number.
In an optional embodiment, further includes:
Request module is additionally configured to obtain the answer data of candidate, sends synchronization request, the synchronization to server-side
The answer data are carried in request;
First receiving module: it is configured as asking by server-side to the synchronization that database transmission carries the answer data
It asks, and receives the third versions of data number that the database is sent;
Determining module is additionally configured to when the versions of data number for determining the client is consistent with the third version number,
The answer data are uploaded to the database, and receive the 4th data that the database root is updated according to the answer data
Version number;
Update module is additionally configured to the versions of data number of the client being updated to versions of data No. the 4th;
In an optional embodiment, which is characterized in that further include:
Determining module is additionally configured to work as the versions of data number for determining the client and the third versions of data number not
When consistent, the data information and the database updated in the database relative to the versions of data number of the client is received
Send the versions of data No. the 5th updated after data information;
Update module is additionally configured to the versions of data number of the client being updated to versions of data No. the 5th;
Second receiving module: it is configured as the answer data being uploaded to the database, and receives the database
The versions of data No. the 6th updated according to the answer data;
Update module is additionally configured to versions of data No. the 5th of the client being updated to versions of data No. the 6th.
In an optional embodiment, the determining module includes:
First receiving unit: it is configured as receiving the structured data information of paper to be set the exam;
Display unit: it is configured as obtaining the first examination question data of paper according to the structured data information, described in caching
First examination question data simultaneously show the first examination question data according to preset exhibition strategy.
In an optional embodiment, the determining module includes:
Acquiring unit: be configured as obtain candidate answer data and the answer progress msg, by answer data into
Row caching;
The acquiring unit is additionally configured to be requested according to the answer progress msg and structured data information to server
Second examination question data receive and cache the second examination question data;
The display unit is additionally configured to show the second examination question data according to the preset exhibition strategy, receives
The answer data of candidate simultaneously cache;
Uploading unit: it is configured as uploading the tactful answer data that will be cached in a manner of incremental transmission according to preset
It is uploaded to server.
In an optional embodiment, the preset upload strategy includes:
The answer data for setting number road examination question are uploaded in batches or carry out answer data in batches according to setting byte number
It uploads or uploads answer data in batches according to the examination question page number.
A kind of calculating equipment is also provided in one embodiment of this specification, including memory, processor and is stored in memory
Computer instruction that is upper and can running on a processor, the processor realize the data side of synchronization when executing described instruction
The step of method.
One embodiment of this specification also provides a kind of computer readable storage medium, is stored with computer instruction, this refers to
The step of method of data synchronization is realized when order is executed by processor.
A kind of exemplary scheme of above-mentioned computer readable storage medium for the present embodiment is it should be noted that the storage
The technical solution of medium and the technical solution of above-mentioned method of data synchronization belong to same design, and the technical solution of storage medium is not
The detail content of detailed description may refer to the description of the technical solution of above-mentioned method of data synchronization.
The computer instruction includes computer program code, the computer program code can for source code form,
Object identification code form, executable file or certain intermediate forms etc..The computer-readable medium may include: that can carry institute
State any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic disk, CD, the computer storage of computer program code
Device, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory),
Electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that the computer-readable medium include it is interior
Increase and decrease appropriate can be carried out according to the requirement made laws in jurisdiction with patent practice by holding, such as in certain jurisdictions of courts
Area does not include electric carrier signal and telecommunication signal according to legislation and patent practice, computer-readable medium.
It should be noted that for the various method embodiments described above, describing for simplicity, therefore, it is stated as a series of
Combination of actions, but those skilled in the art should understand that, this specification is not limited by the described action sequence, because
For according to this specification, certain steps can use other sequences or carry out simultaneously.Secondly, those skilled in the art also should
Know, the embodiments described in the specification are all preferred embodiments, and related actions and modules might not all be this
Necessary to specification.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodiment
Point, it may refer to the associated description of other embodiments.
This specification preferred embodiment disclosed above is only intended to help to illustrate this specification.Alternative embodiment is not
All details of detailed descriptionthe, do not limit the invention to the specific embodiments described.Obviously, according in this specification
Hold, can make many modifications and variations.These embodiments are chosen and specifically described to this specification, is in order to preferably explain this theory
The principle and practical application of bright book, so that skilled artisan be enable to better understand and utilize this specification.This
Specification is limited only by the claims and their full scope and equivalents.