Background technology
The system that on a lot of servers, moves, in service in system, some configuration need be configured by the backstage, and these configurations generally are stored in the database (Database), are convenient to provide the WEB interface for users to revise.The list structure of existing database is totally two fields, is respectively parameter name and parameter value, when configuration data changes, wishes that server program can get access to timely, and according to the configuration that changes, carries out different flow processs.
Existing mode is that server regularly obtains all data in the database configuration table, compares with local current configuration then, finds difference, and explanation changes, and carries out associative operation then.
Though can realize purpose like this, but efficient is very low, at first, whether configuration variation is a small probability event, but no matter change, need obtain all data in the allocation list at every turn, when allocation list was big, volume of transmitted data was bigger, secondly, compare successively in server program, efficient is also lower.
Summary of the invention
Fundamental purpose of the present invention has been to provide a kind of method, Apparatus and system that obtains the database update data, obtains the efficient of Data Update and reduces volume of transmitted data with raising.
For reaching above-mentioned purpose, the present invention discloses a kind of method of obtaining the database update data, comprising:
Server obtains allocation list from database, the list structure of described allocation list at least by parameter name, parameter value and update time three fields form;
Described server loads all configurations in the described allocation list, and writes down the maximal value of update time in all configurations;
Described server detects in the allocation list of described database whether arranged the update time bigger than the maximal value of current record, if having, loads all update times of the configuration bigger than the maximal value of described server current record from the allocation list of described database;
Described server loads the back and before detecting in all that finish this next time, and the maximal value of update time of precedence record is updated to the maximal value that this loads the update time of configuration correspondence.
For reaching above-mentioned purpose, the present invention also discloses a kind of system that obtains the database update data fast, comprising: database and server;
Described database storing has allocation list, the list structure of described allocation list at least by parameter name, parameter value and update times three the word field form;
Described server is used for obtaining allocation list from described database, loads all configurations in the described allocation list, and writes down the maximal value of update time in all configurations; Detect afterwards in the allocation list of described database whether arranged the update time bigger than the maximal value of current record, if have, from the allocation list of described database, load all update times of the configuration bigger than the maximal value of described server current record, and load the back and before detecting in all that finish this next time, the maximal value of update time of precedence record is updated to the maximal value that this loads the update time of configuration correspondence.
For reaching above-mentioned purpose, the present invention also provides a kind of database, the list structure of its allocation list at least by parameter name, parameter value and update time three fields form.
For reaching above-mentioned purpose, the present invention also discloses a kind of server, comprising:
Load-on module is used for obtaining allocation list from described database, loads all configurations in the described allocation list, and in the detection module record maximal value of update time;
Described detection module, be used for the allocation list that maximal value according to update time of record detects database whether arranged the update time bigger than the maximal value of current record, if have, enable described load-on module and from the allocation list of described database, load all update times of the configuration bigger than the maximal value of described server current record;
Described load-on module also is used for loading the back and before detecting in all that finish this next time, and the maximal value of update time of precedence record is updated to the maximal value that this loads the update time of configuration correspondence.
Compared with prior art, method, the Apparatus and system that obtains the database update data disclosed by the invention has the following advantages at least:
Only when configuration changes, could from allocation list, take out data, when so just guaranteeing to have only configuration variation, just have the comparison of data and the more transmission of new data, the cycle of can the scaled-back server detecting, thus greatly improve the efficient of obtaining the database update data and reduced volume of transmitted data.
Embodiment
Database be according to data structure organize, the warehouse of storage and management data, it has number of different types, has all obtained in all fields using widely to the large-scale database system that can carry out mass data storage from the simplest form that stores various data.Below in conjunction with Figure of description to method, the Apparatus and system that obtains the database update data fast of the present invention.
Embodiment one
Present embodiment discloses a kind of method of obtaining the database update data fast.Wherein the list structure of the allocation list of this database is as shown in table 1:
| Parameter name | |
| Parameter value | |
| Update time | |
Table 1
As known from Table 1, the list structure of its allocation list be provided with parameter name, parameter value and update time three fields.Among the present invention, configuration is the storage unit of database minimum.Being presented on the server interface or list is made up of several configuration institutes usually.Configuration information in the allocation list wherein of the present invention can be log-on messages such as the member's of system age, sex, native place, mailbox, contact method; it also can be the configuration information of the software and hardware of server normal operation; can also be server finish with network in the configuration information of the mutual required communication mechanism of other node; those skilled in the art any can think of configuration information all belong to protection scope of the present invention, follow-up repeating no more.
The method of obtaining the database update data disclosed in this invention is based on the database of above-mentioned table 1, and as shown in Figure 1, this method specifically comprises:
Step S1, start server, finish the initial work of server.The described server of present embodiment includes but not limited to the WEB server.
Step S2, server obtain allocation list from database, load all configurations in the allocation list, and write down the maximal value of update time in all configurations.
Among the present invention, the maximal value of update time is the value of up-to-date update time, generally also is the value with nearest update time server current time, follow-up repeating no more.
After this step was complete, webmaster or other application program may be revised the configuration data in the allocation list in the database.Wherein, preferable when revising configuration data, the current time that database writes down this database in the update time of modification configuration data in the field automatically; And in other application scenarios, also can write temporal information in field update time by webmaster.
Step S3, server detect regularly in the allocation list of database whether arranged the update time bigger than the maximal value of current record.If have, change step S4, if do not have, timing detects to wait for next time.
Step S4, server load all update times of the configuration bigger than the maximal value of server current record from the allocation list of database.After finishing, loading changes step S5.
In this step, if an allocation list has 100 configurations, wherein have only a configuration that renewal has taken place, then in the process that loads, data quantity transmitted also is the pairing data volume of this configuration between database and this server; Than the existing allocation list that reloads, data quantity transmitted has die-offed 100 times.In like manner, when this allocation list had only two configuration datas to take place to upgrade, data quantity transmitted had die-offed 50 times than existing method between server of the present invention and the database.
Step S5, server are updated to the maximal value that this loads the update time of configuration correspondence with the maximal value of the update time of precedence record.After renewal is finished, change step S3 to carry out next circulation.
Among the present invention, only be under the prerequisite of small probability event in the variation of configuration data, the die-offing of transmitted data amount (with reference to the example of step S4) created condition for the cycle that shortens server and regularly detect.For example, the cycle that existing method regularly detects is 1 minute, and the cycle that the present invention then can regularly detect it has shortened 5 seconds, thereby makes the present invention greatly improve the efficient of obtaining the database update data and reduced volume of transmitted data.
What deserves to be explained is that in other embodiments, above-mentioned server also can not adopt the mode that regularly detects to remove execution in step S3, but with relevant event trigger mechanism to trigger relevant detection process and subsequent step S4 and step S5.
Embodiment two
Embodiment is corresponding with said method, and present embodiment discloses a kind of system that obtains the database update data.As shown in Figure 2, this system comprises: server 1 and the database 2 that connects thereof, and its connected mode can be a wired connection, also can be wireless connections, the network that can be based on the internet connects, and also can be based on communicating to connect of mobile radio communication and/or PSTN net.
The disclosed database 2 of present embodiment stores allocation list, and the list structure of its allocation list can be with reference to above-mentioned table 1, its at least by parameter name, parameter value and update times three the word field form.Wherein, server 1 is used for obtaining allocation list from database 2, loads all configurations in the allocation list, and writes down the maximal value of update time in all configurations; Detect afterwards in the allocation list of database 2 whether arranged the update time bigger than the maximal value of current record, if have, from the allocation list of database 2, load of the maximal value bigger configuration of all update times than server 1 current record, and load the back and before detecting in all that finish this next time, the maximal value of update time of precedence record is updated to the maximal value that this loads the update time of configuration correspondence.
As shown in Figure 2, in a specific embodiment, above-mentioned server 1 can comprise the following function module at least:
Load-onmodule 10 is used for obtaining allocation list from database 2, loads all configurations in the allocation list, and writes down the maximal value of update time at detection module 20.And this load-onmodule 10 also is used for loading the back and before detecting finishing when last time all next time, and the maximal value of update time of precedence record is updated to the maximal value that this loads the update time of disposing correspondence.
Detection module 20, be used for the allocation list that maximal value according to update time of record detects database 2 whether arranged the update time bigger than the maximal value of current record, if have, enable load-onmodule 10 and from the allocation list of database 2, load of the maximal value bigger configuration of all update times than server 1 current record.
Preferable, the disclosed system of present embodiment also further comprises the webmaster that is connected with database 2 or other application program (not shown); The server of above-mentioned database 2 then also is used for when arbitrary configuration of the allocation list of webmaster or application modification database, revises the update time of response configuration in the allocation list automatically.
The disclosed system that obtains the database update data of present embodiment, only when configuration changes, could from allocation list, take out data, when so just guaranteeing to have only configuration variation, just have the comparison of data and the more transmission of new data, the cycle of can the scaled-back server detecting, thus greatly improve the efficient of obtaining the database update data and reduced volume of transmitted data.
More than disclosed only be several specific embodiment of the present invention, still, the present invention is not limited thereto, any those skilled in the art can think variation all should fall into protection scope of the present invention.