CN105843895B - Data query and synchronous method based on Ehcache, apparatus and system - Google Patents

Data query and synchronous method based on Ehcache, apparatus and system Download PDF

Info

Publication number
CN105843895B
CN105843895B CN201610166470.4A CN201610166470A CN105843895B CN 105843895 B CN105843895 B CN 105843895B CN 201610166470 A CN201610166470 A CN 201610166470A CN 105843895 B CN105843895 B CN 105843895B
Authority
CN
China
Prior art keywords
data
version number
number
major key
ehcache
Prior art date
Application number
CN201610166470.4A
Other languages
Chinese (zh)
Other versions
CN105843895A (en
Inventor
金明晔
何佳
庞敏
Original Assignee
北京建飞无限科技有限公司
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 北京建飞无限科技有限公司 filed Critical 北京建飞无限科技有限公司
Priority to CN201610166470.4A priority Critical patent/CN105843895B/en
Publication of CN105843895A publication Critical patent/CN105843895A/en
Application granted granted Critical
Publication of CN105843895B publication Critical patent/CN105843895B/en

Links

Abstract

The embodiment of the invention provides data query and synchronous method based on Ehcache, apparatus and systems.The described method includes: server receives the inquiry request that client is initiated;Server initiates inquiry request to Ehcache buffer service and database simultaneously and finds out first version number corresponding with major key in Ehcache buffer service according to the major key in inquiry request, finds out the second edition number corresponding with major key in the database;It determines first version number and which version number in the second edition number is newer.The above method can be improved inquiry velocity, and guarantee that returning to the data of client is always latest data.

Description

Data query and synchronous method based on Ehcache, apparatus and system

Technical field

The present invention relates to data query field, in particular to data query and synchronous method based on Ehcache, Apparatus and system.

Background technique

Currently, common data query means are that client is directly inquired from database, this method needs will be hard It is slower to inquire data to memory for reading data in disk;Another common means are that client is first carried out from memory cache Inquiry, if inquired from database without data to be checked, but in this method, if database data is by backstage Operation maintenance personnel modification is not newest it will cause the data for returning to client without modifying the data in memory cache Data.

Summary of the invention

In view of this, the data query and synchronous method of the embodiment of the present invention being designed to provide based on Ehcache, dress It sets and system.

Data query and synchronous method provided in an embodiment of the present invention based on Ehcache, comprising:

Server receives the inquiry request that client is initiated, and includes major key in the inquiry request;

The server initiates the inquiry request to Ehcache buffer service and database simultaneously, according to the inquiry The major key in request finds out first version number corresponding with the major key, in institute in the Ehcache buffer service It states and finds out the second edition number corresponding with the major key in database;

Determine that the first version number and which version number in the second edition number are newer version number,

When the first version number be newer version number when, then from the Ehcache buffer service search with it is described Corresponding first data of major key return to the client, and send first update instruction to the database, so that the number Corresponding second data of the major key are updated to first data according to library response first update instruction, by the second edition Number it is revised as the first version number;

When the second edition number is newer version number, then search from the database corresponding with the major key Second data, and the client is returned to, and send the second more new command to the Ehcache buffer service, so that described Ehcache buffer service responds the described second more new command and corresponding first data of the major key is updated to second number According to the first version number is revised as the second edition number.

Data query and synchronizing device provided in an embodiment of the present invention based on Ehcache, runs on server, described Device includes:

Receiving module includes major key in the inquiry request for receiving the inquiry request of client initiation;

First enquiry module, for initiating the inquiry request to Ehcache buffer service and database simultaneously, according to institute The major key in inquiry request is stated, first version corresponding with the major key is found out in the Ehcache buffer service Number, the second edition number corresponding with the major key is found out in the database;

Determination module is newer version for determining the first version number with which version number in the second edition number This number;

Second enquiry module, for caching and taking from the Ehcache when the first version number is newer version number The first data corresponding with the major key are searched in business, when the second edition number is newer version number, from the data The second data corresponding with the major key are searched in library;

Data return module, for by first data found out from the Ehcache buffer service or from Second data found out in the database return to the client;

Update module, for when the first version number is newer version number, Xiang Suoshu database to send first more New command, so that corresponding second data of the major key are updated to first data by database response first update instruction, The second edition number is revised as the first version number, when the second edition number is newer version number, and to institute It states Ehcache buffer service and sends the second more new command, so that the Ehcache buffer service responds the second more new command for institute It states corresponding first data of major key and is updated to second data, the first version number is revised as the second edition number.

Data query and synchronization system provided in an embodiment of the present invention based on Ehcache, including client, Ehcache Buffer service, database and server,

The client includes major key in the inquiry request for initiating inquiry request to the server;

The server, described in Ehcache buffer service and the database initiation inquiry request, determining simultaneously First version number is newer version number with which version number in the second edition number, when the first version number is newer When version number, Xiang Suoshu database sends first update instruction, when the second edition number is newer version number, Xiang Suoshu Ehcache buffer service sends the second more new command, be also used to find out from the Ehcache buffer service described the One data or second data found out from the database return to the client;

The Ehcache buffer service, for receiving the inquiry request of the initiation from the server, according to institute The major key in inquiry request is stated, first version number corresponding with the major key is found out and returns to the server, also For to corresponding first data of the server return major key, and the second more new command of response that the major key is corresponding The first data be updated to second data, the first version number is revised as the second edition number;

The database is asked for receiving the inquiry request of the initiation from the server according to the inquiry The major key in asking finds out the second edition number corresponding with the major key and returns to the server, is also used to institute It states server and returns to corresponding second data of the major key, and response first update instruction counts the major key corresponding second According to first data are updated to, the second edition number is revised as the first version number.

Compared with prior art, the method for the data query and synchronization provided in an embodiment of the present invention based on Ehcache, dress It sets and system, by each inquiry, major key in the corresponding first version number of major key and database in confirmation Ehcache service Which is newer version number to the corresponding second edition number, to confirm the major key corresponding first number in Ehcache service According to whether being newest, if so, searching and returning corresponding first data from Ehcache service memory at once, can make in this way It is most fast to obtain search speed, on the other hand, if backstage operation maintenance personnel has modified the corresponding data of major key in database, without repairing Change the corresponding data of major key in Ehcache service, at this time by the judgement of version number, the data for returning to client are from data It is found in library, ensure that the data for returning to client are newest data, also, after return client, according to feelings The difference of condition sends more new command to Ehcache service or database data at once, so that Ehcache service and database In data keep synchronize, guarantee next time inquire when can preferentially from Ehcache service memory in returned data, accelerate Inquiry velocity.

To enable the above objects, features and advantages of the present invention to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate Appended attached drawing, is described in detail below.

Detailed description of the invention

In order to illustrate the technical solution of the embodiments of the present invention more clearly, below will be to needed in the embodiment attached Figure is briefly described, it should be understood that the following drawings illustrates only certain embodiments of the present invention, therefore is not construed as pair The restriction of range for those of ordinary skill in the art without creative efforts, can also be according to this A little attached drawings obtain other relevant attached drawings.

Fig. 1 is server provided in an embodiment of the present invention and the schematic diagram that client interacts.

Fig. 2 is a kind of block diagram of server-side provided in an embodiment of the present invention.

Fig. 3 is that one embodiment of the invention provides the flow chart of data query and synchronous method based on Ehcache.

Fig. 4 is the flow chart another embodiment of the present invention provides the data query based on Ehcache and synchronous method.

Fig. 5 is that the functional module for the device that one embodiment of the invention provides the data query based on Ehcache and synchronization is shown It is intended to.

Fig. 6 is the data query and synchronization system based on Ehcache that one embodiment of the invention provides.

Main element symbol description:

Server-side 100, client 200, network 300, the data query based on Ehcache and synchronizing device 110, memory 120, storage control 130, processor 140, Peripheral Interface 150, input-output unit 160, receiving module 111, first are inquired 112, judgment module 113, the second enquiry module 114, data return module 115, update module 116, Ehcache buffer service 400, database 500, server 600.

Specific embodiment

Below in conjunction with attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete Ground description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Usually exist The component of the embodiment of the present invention described and illustrated in attached drawing can be arranged and be designed with a variety of different configurations herein.Cause This, is not intended to limit claimed invention to the detailed description of the embodiment of the present invention provided in the accompanying drawings below Range, but it is merely representative of selected embodiment of the invention.Based on the embodiment of the present invention, those skilled in the art are not doing Every other embodiment obtained under the premise of creative work out, shall fall within the protection scope of the present invention.

It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing.Meanwhile of the invention In description, term " first ", " second " etc. are only used for distinguishing description, are not understood to indicate or imply relative importance.

It is the server-side 100 that present pre-ferred embodiments provide and the schematic diagram that client 200 interacts shown in Fig. 1. As shown in Figure 1, the server-side 100 is communicatively coupled by network and one or more clients 200, it is logical to carry out data Letter or interaction.In the present embodiment, the server-side 100 be may be, but not limited to, web (website) server, ftp (filetransfer protocol, File Transfer Protocol) server etc..The client 200 may be, but not limited to, intelligence It can mobile phone, PC (personal computer, PC), tablet computer, personal digital assistant (personal digital Assistant, PDA), mobile internet surfing equipment (mobile Internet device, MID) etc..The network 300 can be, But it is not limited to, cable network or wireless network.The operating system of the client 200 may be, but not limited to, Android (Android) system, IOS (iPhone operating system) system, Windows phone system, Windows system Deng.

As shown in Fig. 2, being the block diagram of the server-side 100.The server-side includes the data based on Ehcache Inquiry and synchronizing device 110, memory 120, storage control 130, processor 140, Peripheral Interface 150, input-output unit 160。

The memory 120, storage control 130, processor 140, Peripheral Interface 150,160 each yuan of input-output unit Part is directly or indirectly electrically connected between each other, to realize the transmission or interaction of data.For example, these elements between each other may be used It is realized and is electrically connected by one or more communication bus or signal wire.The data query and synchronous dress based on Ehcache Setting 110 includes that at least one can be stored in the memory 120 or solidify in the form of software or firmware (firmware) Software function module in the operating system (operating system, OS) of server-side 100.The processor 140 is used for The executable module stored in memory 120 is executed, such as the data query and synchronizing device 110 based on Ehcache wraps The software function module or computer program included.

Wherein, memory 120 may be, but not limited to, random access memory (Random Access Memory, RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read- Only Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..Wherein, memory 120 is for storing program, and the processor 140 is after receiving and executing instruction, described in execution Program, method performed by the server that the stream process that aforementioned any embodiment of the embodiment of the present invention discloses defines can be applied to In processor, or realized by processor.

Processor 140 may be a kind of IC chip, the processing capacity with signal.Above-mentioned processor 140 can To be general processor, including central processing unit (Central Processing Unit, abbreviation CPU), network processing unit (Network Processor, abbreviation NP) etc.;Can also be digital signal processor (DSP), specific integrated circuit (ASIC), Ready-made programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hard Part component.It may be implemented or execute disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor It can be microprocessor or the processor be also possible to any conventional processor etc..

Various input/output devices are couple processor and memory by the Peripheral Interface 150.In some embodiments In, Peripheral Interface, processor and storage control can be realized in one single chip.In some other example, Ta Menke To be realized respectively by independent chip.

Input-output unit 160 is used to be supplied to the interaction that user input data realizes user and the server-side 100.Institute Stating input-output unit 160 may be, but not limited to, mouse and keyboard etc..

Referring to Fig. 3, being that the data shown in Fig. 2 based on Ehcache that are applied to that present pre-ferred embodiments provide are looked into Inquire about the flow chart of the method for the data query based on Ehcache and synchronization of synchronizing device 110.It below will be to shown in Fig. 3 Detailed process is described in detail.

Step S310, server receive the inquiry request that client is initiated, and include major key in the inquiry request;

Preferably, before the inquiry request that the step S310 server receives that client is initiated, further includes: setting institute It states in the parameter overflowToDisk and parameter diskPersistent in the configuration file of Ehcache cache server extremely A few parameter is true.

The parameter overflowToDisk being arranged in the configuration file of the Ehcache cache server is that very, can make Obtaining Ehcache cache server can be realized while writing memory and hard disk.The configuration text of the Ehcache cache server is set Parameter diskPersistent in part is that very, Ehcache cache server can be enabled to restore rapidly in failure.

Step S320, the server initiate the inquiry request to Ehcache buffer service and database simultaneously, according to The major key in the inquiry request finds out the first edition corresponding with the major key in the Ehcache buffer service This number, the second edition number corresponding with the major key is found out in the database;

It is noted that the database is according to the prior typing number of (major key, the second data, the second edition number) mode According to, when server is inquired at the beginning, the Ehcache buffer service does not have a data, server from the database into Row inquiry, after the second data are returned to client by server, and according to format (major key, the first data, first version number) Ehcache buffer service is write, the value of the first data is identical as the value of the second data at this time, the value and the second edition of first version number Number value it is identical, when inquiring next time, server can then be searched from database and Ehcache buffer service simultaneously according to major key To the corresponding data of major key.

When operation maintenance personnel modifies data in the database when backstage, revision number can be corresponded to, therefore version number is newer, then Corresponding data are then relatively new, and by confirmation, whether version number is consistent, to confirm the same major key respectively in Ehcache buffer service And whether corresponding data are consistent in database.

Step S330 determines that the first version number and which version number in the second edition number are newer version Number, when the second edition number is newer version number, step S340 to step S342 is executed, when the first version number is When newer version number, step S350 to step S352 is executed;

Further, determine that the first version number and which version number in the second edition number are newer version Number, it can specifically include: the size of the first version number and the second edition number;If the first version number is big In the second edition number, it is determined that the first version number is newer version number, if the first version number is less than institute State the second edition number, it is determined that the second edition number is newer version number, if the first version number is equal to described the Two version numbers, it is determined that the first version number is identical as the second edition number.Certainly, the version number of different-format, version Number new and old judgment mode can also be different, for example, if version number is ended up with letter, the confirmation of new and old edition number It can be confirmed according to scheduled letter sequence.

Step S340 searches the second data corresponding with the major key from the database;

Second data are returned to the client by step S341;

Step S342, Xiang Suoshu Ehcache buffer service sends the second more new command, so that Ehcache caching clothes Corresponding first data of the major key are updated to second data by business the described second more new command of response, by the first edition This number is revised as the second edition number, terminates process.

Step S350 searches the first data corresponding with the major key from the Ehcache buffer service;

First data are returned to the client by step S351;

Step S352, Xiang Suoshu database sends first update instruction, so that the database response first update instruction Corresponding second data of the major key are updated to first data, the second edition number is revised as the first version Number, terminate process.

In conclusion the method for the data query and synchronization provided in this embodiment based on Ehcache, by looking into every time When inquiry, in confirmation Ehcache service in the corresponding first version number of major key and database the corresponding second edition number of major key which For newer version number, to confirm whether the major key corresponding first data in Ehcache service are newest, if so, Corresponding first data are searched and return from Ehcache service memory at once, such that search speed is most fast, another party Face, if backstage operation maintenance personnel has modified the corresponding data of major key in database, without modifying major key pair in Ehcache service The data answered, at this time by the judgement of version number, the data for returning to client are found from database, be ensure that and are returned Data back to client are newest data.Also, after returning to client, depending on the situation, at once to Ehcache Service or database data send more new command, so that the data in Ehcache service and database keep synchronizing, under guarantee Returned data in memory preferentially can be serviced from Ehcache when one query, accelerate inquiry velocity.

Referring to Fig. 4, being that the data shown in Fig. 2 based on Ehcache that are applied to that present pre-ferred embodiments provide are looked into Inquire about another flow chart of the method for the data query based on Ehcache and synchronization of synchronizing device 110.It below will be to Fig. 4 institute The detailed process shown is described in detail.

Step S410, server receive the inquiry request that client is initiated, and include major key in the inquiry request;

It preferably, can also include: to set before the inquiry request that the step S310 server receives that client is initiated It sets in the parameter overflowToDisk and parameter diskPersistent in the configuration file of the Ehcache cache server At least one parameter be true.

The parameter overflowToDisk being arranged in the configuration file of the Ehcache cache server is that very, can make Obtaining Ehcache cache server can be realized while writing memory and hard disk.The configuration text of the Ehcache cache server is set Parameter diskPersistent in part is that very, Ehcache cache server can be enabled to restore rapidly in failure.

Step S420, the server initiate the inquiry request to Ehcache buffer service and database simultaneously, according to The major key in the inquiry request finds out the first edition corresponding with the major key in the Ehcache buffer service This number, the second edition number corresponding with the major key is found out in the database;

It is noted that it is corresponding to find out major key in Ehcache buffer service and database according to major key Version number and the corresponding data of major key, when operation maintenance personnel modifies data in the database when backstage, revision number can be corresponded to, Therefore version number is newer, then corresponding data are then relatively new, and by confirmation, whether version number is consistent, to confirm the same major key difference Whether corresponding data are consistent in Ehcache buffer service and database.

Step S430 determines that the first version number and which version number in the second edition number are newer version Number, when the second edition number is newer version number, it is transferred to step S440 to step S443, when the first version number is When newer version number, step S450 is transferred to step S452.

Step S440 then searches the second data corresponding with the major key from the database;

Step S441 converts the second data that relational model data indicate to by the POJO object of enumeration type definition The data that data model in memory indicates;

It is noted that the data of storage in the database are the data indicated with relational model data, it is stored in Data in Ehcache buffer service and the data for returning to client require the number indicated with the data model in memory According to, it is therefore desirable to the second data for indicating relational model data are converted into the data of the expression of the data model in memory, this reality This conversion is carried out using the POJO object of enumeration type definition in example, because the definition of enumeration type is simple, significantly This transfer efficiency is improved, so that inquiry velocity becomes faster.

Data after conversion are returned to the client by step S442;

Step S443, Xiang Suoshu Ehcache buffer service sends the second more new command, so that Ehcache caching clothes Corresponding first data of the major key are updated to second data by business the described second more new command of response, by the first edition This number is revised as the second edition number, terminates process.

When the first version number is newer version number, step S450 is transferred to step S452 by step S420.

Step S450 searches the first data corresponding with the major key from the Ehcache buffer service, is transferred to step S451;

First data are returned to the client, are transferred to step S452 by step S451;

Step S452, Xiang Suoshu database sends first update instruction, so that the database response first update instruction Corresponding second data of the major key are updated to first data, the second edition number is revised as the first version Number, terminate process.

In conclusion the method for the data query and synchronization provided in this embodiment based on Ehcache, further passes through The conversion that data model of the relational model data into memory is done using the POJO type of enumeration type definition, is substantially increased Transfer efficiency, so that inquiry velocity becomes faster.

Referring to Fig. 5, being data query shown in Fig. 2 based on Ehcache that present pre-ferred embodiments provide and same Walk the functional block diagram of device 110.The data query and synchronizing device 110 based on Ehcache includes receiving module 111, the first enquiry module 112, judgment module 113, the second enquiry module 114, data return module 115, update module 116.

The receiving module 111 includes major key in the inquiry request for receiving the inquiry request of client initiation;

First enquiry module 112 is asked for initiating the inquiry to Ehcache buffer service and database simultaneously It asks, according to the major key in the inquiry request, is found out in the Ehcache buffer service corresponding with the major key First version number finds out the second edition number corresponding with the major key in the database;

The determination module 113, for determining the first version number is with which version number in the second edition number Newer version number;

Second enquiry module 114, for when the first version number is newer version number, from described The first data corresponding with the major key are searched in Ehcache buffer service, when the second edition number is newer version number When, the second data corresponding with the major key are searched from the database;

The data return module 115, first data for will be found out from the Ehcache buffer service Or second data found out from the database return to the client;

The update module 116, for when the first version number is newer version number, Xiang Suoshu database to be sent First update instruction, so that corresponding second data of the major key are updated to described first by database response first update instruction The second edition number is revised as the first version number by data, when the second edition number is newer version number, and The second more new command is sent to the Ehcache buffer service, so that the Ehcache buffer service responds the second more new command Corresponding first data of the major key are updated to second data, the first version number is revised as the second edition Number.

Preferably, in other embodiments, the data query and synchronizing device 110 based on Ehcache further includes turning Block is changed the mold, the second data that the conversion module is used to indicate relational model data are converted into memory by POJO object The data that data model indicates.

Referring to Fig. 6, being the data query and synchronization system based on Ehcache that present pre-ferred embodiments provide, packet Include client 200, Ehcache buffer service 400, database 500 and server 600.

The client 200 includes major key in the inquiry request for initiating inquiry request to the server 600;

The server 600 is asked for initiating the inquiry to Ehcache buffer service 400 and database 500 simultaneously It asks, determines that the first version number and which version number in the second edition number are newer version number, when the first edition This number be newer version number when, Xiang Suoshu database 500 send first update instruction, when the second edition number be it is newer When version number, Xiang Suoshu Ehcache buffer service 400 sends the second more new command, is also used to that clothes will be cached from the Ehcache First data found out or second data found out from the database 500 return to institute in business 400 State client 200;

The Ehcache buffer service 400, for receiving the inquiry request of the initiation from the server 600, According to the major key in the inquiry request, finds out first version number corresponding with the major key and return to the service Device 600 is also used to return corresponding first data of the major key to the server 600, and the second more new command of response will Corresponding first data of the major key are updated to second data, and the first version number is revised as the second edition Number;

The database 500, for receiving the inquiry request of the initiation from the server 600, according to described The major key in inquiry request finds out the second edition number corresponding with the major key and returns to the server 600, also For returning to corresponding second data of the major key to the server 600, and response first update instruction is by the major key Corresponding second data are updated to first data, and the second edition number is revised as the first version number.

In several embodiments provided herein, it should be understood that disclosed device and method can also pass through Other modes are realized.The apparatus embodiments described above are merely exemplary, for example, flow chart and block diagram in attached drawing Show the device of multiple embodiments according to the present invention, the architectural framework in the cards of method and computer program product, Function and operation.In this regard, each box in flowchart or block diagram can represent the one of a module, section or code Part, a part of the module, section or code, which includes that one or more is for implementing the specified logical function, to be held Row instruction.It should also be noted that function marked in the box can also be to be different from some implementations as replacement The sequence marked in attached drawing occurs.For example, two continuous boxes can actually be basically executed in parallel, they are sometimes It can execute in the opposite order, this depends on the function involved.It is also noted that every in block diagram and or flow chart The combination of box in a box and block diagram and or flow chart can use the dedicated base for executing defined function or movement It realizes, or can realize using a combination of dedicated hardware and computer instructions in the system of hardware.

In addition, each functional module in each embodiment of the present invention can integrate one independent portion of formation together Point, it is also possible to modules individualism, an independent part can also be integrated to form with two or more modules.

It, can be with if the function is realized and when sold or used as an independent product in the form of software function module It is stored in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially in other words The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention. And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access The various media that can store program code such as memory (RAM, Random Access Memory), magnetic or disk.It needs It is noted that herein, relational terms such as first and second and the like are used merely to an entity or operation It is distinguished with another entity or operation, without necessarily requiring or implying between these entities or operation, there are any this Actual relationship or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to nonexcludability It include so that the process, method, article or equipment for including a series of elements not only includes those elements, but also to wrap Include other elements that are not explicitly listed, or further include for this process, method, article or equipment intrinsic want Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want There is also other identical elements in the process, method, article or equipment of element.

The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, made any to repair Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.It should also be noted that similar label and letter exist Similar terms are indicated in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, are then not required in subsequent attached drawing It is further defined and explained.

The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain Lid is within protection scope of the present invention.Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. data query and synchronous method based on Ehcache characterized by comprising
Server receives the inquiry request that client is initiated, and includes major key in the inquiry request;
The server initiates the inquiry request to Ehcache buffer service and database simultaneously, according to the inquiry request In the major key, first version number corresponding with the major key is found out in the Ehcache buffer service, in the number According to finding out the second edition number corresponding with the major key in library;
Determine that the first version number and which version number in the second edition number are newer version number,
When the first version number is newer version number, then searched and the major key from the Ehcache buffer service Corresponding first data return to the client, and send first update instruction to the database, so that the database It responds first update instruction and corresponding second data of the major key is updated to first data, the second edition number is repaired It is changed to the first version number;
When the second edition number is newer version number, then corresponding with the major key second is searched from the database Data, and the client is returned to, and send the second more new command to the Ehcache buffer service, so that described Ehcache buffer service responds the described second more new command and corresponding first data of the major key is updated to second number According to the first version number is revised as the second edition number.
2. the method according to claim 1, wherein when the first version number is identical as the second edition number When, the server searches the first data corresponding with the major key from the Ehcache buffer service, returns to the visitor Family end.
3. method according to claim 1 or 2, which is characterized in that it is described reception client initiate inquiry request it Before, further includes:
Parameter overflowToDisk in the configuration file of the Ehcache cache server and parameter are set At least one parameter in diskPersistent is true.
4. method according to claim 1 or 2, which is characterized in that updated version number is greater than the version number before updating, The determination first version number is newer version number with which version number in the second edition number, comprising:
Compare the size of the first version number with the second edition number;
If the first version number is greater than the second edition number, it is determined that the first version number is newer version number, If the first version number is less than the second edition number, it is determined that the second edition number is newer version number, if The first version number is equal to the second edition number, it is determined that the first version number is identical as the second edition number.
5. the method according to claim 1, wherein being wrapped before second data are returned to client It includes:
The server converts the second data that relational model data indicate to by POJO object the data model in memory The data of expression.
6. according to the method described in claim 5, it is characterized in that, the POJO object uses enumeration type definition.
7. data query and synchronizing device based on Ehcache, run on server, described device includes:
Receiving module includes major key in the inquiry request for receiving the inquiry request of client initiation;
First enquiry module is looked into for initiating the inquiry request to Ehcache buffer service and database simultaneously according to described The major key in request is ask, first version number corresponding with the major key is found out in the Ehcache buffer service, The second edition number corresponding with the major key is found out in the database;
Determination module is newer version for determining the first version number with which version number in the second edition number Number;
Second enquiry module, for when the first version number be newer version number when, from the Ehcache buffer service The first data corresponding with the major key are searched, when the second edition number is newer version number, from the database Search the second data corresponding with the major key;
Data return module, for by first data found out from the Ehcache buffer service or from described Second data found out in database return to the client;
Update module, for when the first version number is newer version number, Xiang Suoshu database to send the first update and refers to It enables, so that corresponding second data of the major key are updated to first data by database response first update instruction, by institute It states the second edition number and is revised as the first version number, when the second edition number is newer version number, and to described Ehcache buffer service sends the second more new command, so that the second more new command of Ehcache buffer service response will be described Corresponding first data of major key are updated to second data, and the first version number is revised as the second edition number.
8. device according to claim 7, which is characterized in that second enquiry module is also used to when the first version When number identical as the second edition number, the first data corresponding with the major key are searched from the Ehcache buffer service.
9. device according to claim 7, which is characterized in that further include conversion module, the conversion module will be for that will close It is that the second data that model data indicates are converted into the data of the data model expression in memory by POJO object.
10. data query and synchronization system based on Ehcache, including client, Ehcache buffer service, database and Server, it is characterised in that:
The client includes major key in the inquiry request for initiating inquiry request to the server;
The server, for initiating the inquiry request to Ehcache buffer service and database simultaneously;
The Ehcache buffer service is looked into for receiving the inquiry request of the initiation from the server according to described The major key in request is ask, first version number corresponding with the major key is found out and returns to the server, be also used to Corresponding first data of the major key are returned to the server;
The database, for receiving the inquiry request of the initiation from the server, according in the inquiry request The major key, find out the second edition number corresponding with the major key and return to the server, be also used to the clothes Business device returns to corresponding second data of the major key;
The server is also used to determine that the first version number and which version number in the second edition number are newer version This number, when the first version number is newer version number, Xiang Suoshu database sends first update instruction, will be from described First data found out in Ehcache buffer service return to the client;When the second edition number is relatively new Version number when, Xiang Suoshu Ehcache buffer service send the second more new command, described in finding out from the database Second data return to the client;
The Ehcache buffer service is also used to respond the described second more new command for corresponding first data of the major key more It is newly second data, the first version number is revised as the second edition number;
The database is also used to respond the first update instruction for corresponding second data of the major key and is updated to described The second edition number is revised as the first version number by one data.
CN201610166470.4A 2016-03-22 2016-03-22 Data query and synchronous method based on Ehcache, apparatus and system CN105843895B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610166470.4A CN105843895B (en) 2016-03-22 2016-03-22 Data query and synchronous method based on Ehcache, apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610166470.4A CN105843895B (en) 2016-03-22 2016-03-22 Data query and synchronous method based on Ehcache, apparatus and system

Publications (2)

Publication Number Publication Date
CN105843895A CN105843895A (en) 2016-08-10
CN105843895B true CN105843895B (en) 2019-07-02

Family

ID=56582951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610166470.4A CN105843895B (en) 2016-03-22 2016-03-22 Data query and synchronous method based on Ehcache, apparatus and system

Country Status (1)

Country Link
CN (1) CN105843895B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107085603A (en) * 2017-03-31 2017-08-22 北京奇艺世纪科技有限公司 A kind of data processing method and device
CN107330119B (en) * 2017-07-14 2018-08-03 掌阅科技股份有限公司 Caching data processing method, electronic equipment, computer storage media
CN108959341A (en) * 2018-04-04 2018-12-07 阿里巴巴集团控股有限公司 A kind of method, device and equipment that data are synchronous

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102426589A (en) * 2011-10-31 2012-04-25 合一网络技术(北京)有限公司 Interlayer system used for searching database information and information searching method
CN103197988A (en) * 2012-01-05 2013-07-10 中国移动通信集团湖南有限公司 Data backup and recovery method, device and database system
CN103457905A (en) * 2012-05-28 2013-12-18 腾讯科技(深圳)有限公司 Data synchronizing method, data synchronizing system and data synchronizing device
CN103645904A (en) * 2013-12-20 2014-03-19 北京京东尚科信息技术有限公司 Cache realization method of interface calling

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7885987B1 (en) * 2001-08-28 2011-02-08 Lee Eugene M Computer-implemented method and system for managing attributes of intellectual property documents, optionally including organization thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102426589A (en) * 2011-10-31 2012-04-25 合一网络技术(北京)有限公司 Interlayer system used for searching database information and information searching method
CN103197988A (en) * 2012-01-05 2013-07-10 中国移动通信集团湖南有限公司 Data backup and recovery method, device and database system
CN103457905A (en) * 2012-05-28 2013-12-18 腾讯科技(深圳)有限公司 Data synchronizing method, data synchronizing system and data synchronizing device
CN103645904A (en) * 2013-12-20 2014-03-19 北京京东尚科信息技术有限公司 Cache realization method of interface calling

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于 Ext 的 J2EE 快速开发研究;李瑞 等;《软件导刊》;20091231;全文

Also Published As

Publication number Publication date
CN105843895A (en) 2016-08-10

Similar Documents

Publication Publication Date Title
US9807192B1 (en) Centralized coordination of data collection tasks from multiple sources
US9720665B2 (en) Utilizing user devices for backing up and retrieving data in a distributed backup system
US8682903B2 (en) System and method for synchronized content directories on cluster devices
JP6130890B2 (en) Data synchronization
CN105190616A (en) Visualizing ranking factors for items in a search result list
US9712645B2 (en) Embedded event processing
US20190073409A1 (en) Search result replication management in a search head cluster
CN201682522U (en) Conversation information storage system and application server
CN103744906A (en) System, method and device for data synchronization
EP2682863A1 (en) Installing applications remotely
CN102707990B (en) Container based processing method and device
US20140317117A1 (en) Method, device and computer storage media for user preferences information collection
CN102096685B (en) Method and device for synchronizing distributive data into data warehouse
US20120271962A1 (en) Achieving Lossless Data Streaming in a Scan Based Industrial Process Control System
CN101072091B (en) Protocol optimization for client and server synchronization
US9158532B2 (en) Methods for managing applications using semantic modeling and tagging and devices thereof
CN103714097A (en) Method and device for accessing database
CN103019960B (en) Distributed caching method and system
DE112011104787B4 (en) Use of content via personal clouds
JP2016524255A (en) Naive client-side sharding with online addition of shards
JP2006134191A (en) Document retrieval method and its system
CN103916482A (en) Data synchronous transmission method based on sqlite
CN103634375A (en) Method, device and equipment for cluster node expansion
US20140129032A1 (en) Genetic learning for environmental control automation
US9977596B2 (en) Predictive models of file access patterns by application and file type

Legal Events

Date Code Title Description
C06 Publication
C10 Entry into substantive examination
GR01 Patent grant