A kind of efficient caching system of serverTechnical field
The utility model relates to a kind of efficient caching system of computer system data disposal system, particularly a kind of server, is applicable to the computer service system that Data Update is more frequent.
Background technology
At present, in the page program of website, generally all can relate to some and be stored in general information in the database, as the province tabulation, commodity classification etc., these information all are identical for each calling party.Usually during each user capture, all to go database to read, be shown to the user then; The database server load is increased the weight of, can't serve prior issued transaction fast, and the web server also must ceaselessly be created database connection object, the consumption ample resources, caused when the user is a lot, the response speed of webpage is very slow.For example, there are 100 people that certain webpage is sent request of access in the same time, so just need from database, read 100 secondary data, send to the people that these send request of access then respectively, be a kind of great waste like this to the database resource of preciousness, very low to the efficient of same categorical data frequent access.
The utility model content
The purpose of this utility model is, a kind of efficient caching system of server is provided, and it can reduce the access of database amount,Improved efficient to same categorical data frequent access.
For solving the problems of the technologies described above, the utility model adopts following technical scheme: a kind of efficient caching system of server comprises:
The web server is used to receive the request of access that the user sends, and sends to the buffer memory service equipment and to write or the request of reading of data;
The buffer memory service equipment is used to read and write data, and perhaps sends the request of reading and writing data to database server, and will read the result and return to the web server;
Wherein, the web server connects the buffer memory service equipment, and the buffer memory service equipment connects database server.
The request of access that described web server sends according to the user is sent to the buffer memory service equipment and is write or the request of reading of data;
Described buffer memory service equipment, the request of sending according to the web server, with data write in the buffer memory service equipment the relevant position or from the relevant position reading of data of buffer memory service equipment, when not having required data that read in the expired or buffer memory service equipment when the data of storing in the buffer memory service equipment, the buffer memory service equipment just sends the operation of fetching data to database server.
In the efficient caching system of aforesaid a kind of server, be provided with the data check module in the described buffer memory service equipment, be used for verification current cache service equipment and whether exist the data of user inquiring or data whether expired; During the data that do not have in the expired or buffer memory service equipment when the data in the buffer memory service equipment to inquire about, the buffer memory service equipment sends the reading of data request to database server, return to the web server obtain data from database server after, the buffer memory service equipment is preserved a simultaneously.
In the efficient caching system of aforesaid a kind of server, described buffer memory service equipment is provided with time block, is used for to the data that the buffer memory service equipment is stored being set effective time.The described setting be meant effective time, data the effective time of setting in the scope effectively.
Described buffer memory is transparent for access program, need not buffer memory be set explicitly.Only need indicate this access, may how long effective.Back buffer memory service equipment can be provided with the result data of this visit the effective time of one section designated length, and in effective time, same request can not impact back-end data base, just directly the result is returned.
Compared with prior art, the utility model is provided with the buffer memory service equipment and is connected with database server, the user during to same categorical data frequent access, the data that obtain by database server in the time of the user can being visited for the first time are stored in the buffer memory service equipment, later visit data can directly read in buffer memory, do not need the accessing database server, reduced the visit capacity of database server,Improved efficient to same categorical data frequent access.
Description of drawings
Fig. 1 is the structural representation of a kind of embodiment of the present utility model;
Fig. 2 is the workflow diagram of a kind of embodiment of the present utility model.
Reference numeral: 1-web server, 2-buffer memory service equipment, 3-database server, 4-data check module, 5-time block.
Below in conjunction with the drawings and specific embodiments the utility model is further described.
Embodiment
Embodiment of the present utility model: a kind of efficient caching system of server, structure is as shown in Figure 1; Comprise:
Web server 1 is used to receive the request of access that the user sends, and sends to buffermemory service equipment 2 and to write or the request of reading of data;
Buffermemory service equipment 2 is used to read and write data, and perhaps sends the request of reading and writing data todatabase server 3, and will read the result and return toweb server 1;
Wherein,web server 1 connects buffermemory service equipment 2, and buffermemory service equipment 2 connectsdatabase server 3.
The request of access that describedweb server 1 sends according to the user is sent to buffermemory service equipment 2 and is write or the request of reading of data;
Described buffermemory service equipment 2, the request of sending according toweb server 1, with data write in the buffermemory service equipment 2 the relevant position or from the relevant position reading of data of buffermemory service equipment 2, when not having required data that read in the expired or buffermemory service equipment 2 of data of storage in the buffermemory service equipment 2, buffermemory service equipment 2 just sends the operation of fetching data todatabase server 3.
Be provided withdata check module 4 in the described buffermemory service equipment 2, be used for verification currentcache service equipment 2 and whether exist the data of user inquiring or data whether expired; During the data that do not have in the expired or buffermemory service equipment 2 when the data in the buffermemory service equipment 2 to inquire about, buffermemory service equipment 2 sends the reading of data request todatabase server 3, return toweb server 1 obtain data fromdatabase server 3 after, buffermemory service equipment 2 is also preserved a data streams read simultaneously.
Described buffermemory service equipment 2 is provided withtime block 5, is used for to the data of buffermemory service equipment 2 storages being set effective time.The described setting be meant effective time, data the effective time of setting in the scope effectively.Be 1min the effective time that present embodiment is provided with data.
Described buffer memory is transparent for access program, need not buffer memory be set explicitly.Only need indicate this access, may how long effective.Back buffer memory service equipment can be provided with the result data of this visit the effective time of one section designated length, and in effective time, same request can not impact back-end data base, just directly the result is returned.
The workflow of a kind of embodiment of the present utility model: (as Fig. 2)
S1, the web server receives the request of access that the user sends;
The request of access that S2, web server send according to the user is sent to the buffer memory service equipment and is write or the request of reading of data;
S3, buffer memory service equipment write or reading of data according to the request of web server, and data streams read is returned to the web server.
Example explanation: such as 1000 certain stars' of user capture homepage was arranged in one minute, this homepage will obtain star's bean vermicelli tabulation, traditional method obtains star's bean vermicelli tabulation, is to read identical data from database 1000 times, is distributed to each user then respectively.If use system of the present utility model, only need read one time the data in the database, these data are kept in the buffer memory, and expired time is set 1 minute, except first user is data in the reading database, all the other 999 people are the results who reads from buffer memory, can save the expense of reading database like this, reduce the frequency of reading database greatly.In addition, because first user is the data that directly read from database, outside the shared time is long slightly, other users are the data that read from buffer memory within expired time, the browser response is fast especially, and the page is presented in face of the user very soon, has brought favorable experience to the user.
Say for another example, the someone has visited 50 pages within 10 minutes, each page all need be obtained good friend's relation, and the possibility that these good friends passes tie up to variation within 10 minutes is little, when not needing so whenever to browse a page, all send the request of friend information in the reading database.Only this friend information need be buffered in the buffer memory service equipment, and 10 minutes expired time are set, can directly fetch data from the buffer memory service equipment when getting good friend's relation within expired time, it is fast to read page data speed, has brought favorable experience to the user.