CN110555040A - Data caching method and device and server - Google Patents

Data caching method and device and server Download PDF

Info

Publication number
CN110555040A
CN110555040A CN201810277589.8A CN201810277589A CN110555040A CN 110555040 A CN110555040 A CN 110555040A CN 201810277589 A CN201810277589 A CN 201810277589A CN 110555040 A CN110555040 A CN 110555040A
Authority
CN
China
Prior art keywords
data
expiration time
data item
time
cache database
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201810277589.8A
Other languages
Chinese (zh)
Inventor
蒋海滔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201810277589.8A priority Critical patent/CN110555040A/en
Publication of CN110555040A publication Critical patent/CN110555040A/en
Pending legal-status Critical Current

Links

Abstract

The application provides a data caching method, a data caching device and a server, wherein the method comprises the following steps: establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time; and if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database. By the technical scheme, service interruption of the client can be avoided, and user experience is improved.

Description

data caching method and device and server
Technical Field
the present application relates to the field of internet technologies, and in particular, to a data caching method, apparatus, and server.
background
the basic idea of CDN (Content Delivery Network) is: links influencing the data transmission speed and stability are avoided as far as possible, so that the data transmission is faster and more stable. As shown in fig. 1, which is a networking diagram of the CDN, the CDN server may distribute data to each CDN node, and each CDN node may store the data locally. When receiving a request message sent by a client, a CDN node may query data matching the request message from a local and send the queried data to the client. Therefore, the client does not need to send the request message to the CDN server, and the CDN server does not need to send data to the client, so that the network bandwidth can be saved, and the data transmission speed can be improved.
When the CDN server distributes data (taking data a as an example) to the CDN node, an expiration time may also be set for the data a, and the CDN node may locally store a correspondence between the data a and the expiration time. Based on this, when it is determined that the data a has expired according to the expiration time, the CDN node may delete the data a and re-request the data a from the CDN server. And if the data A stored locally by the CDN server does not change, the data A is retransmitted to the CDN node, and if the data A stored locally by the CDN server changes into the data B, the changed data B is transmitted to the CDN node.
however, if a link between the CDN node and the CDN server fails, the CDN node cannot download the latest data from the CDN server when requesting the data a again from the CDN server. If a request message for the data a sent by the client is received, the CDN node has deleted the data a, so that data cannot be returned to the client, which causes service interruption of the client and affects user experience.
Disclosure of Invention
the application provides a data caching method, which is applied to a node server and comprises the following steps:
Establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time;
And if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database.
The application provides a data caching method, which is applied to a management server and comprises the following steps:
Acquiring data, and configuring a first expiration time and a second expiration time for the data;
Sending a first message to a node server, wherein the first message carries the data, the first expiration time and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
The application provides a data caching device, is applied to node server, the device includes:
The system comprises an establishing module, a data processing module and a data processing module, wherein the establishing module is used for establishing a cache database, and the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time;
And the processing module is used for reserving the first data item in the cache database when the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time.
The application provides a data caching device, is applied to the management server, the device includes:
The acquisition module is used for acquiring data and configuring first expiration time and second expiration time for the data;
A sending module, configured to send a first message to a node server, where the first message carries the data, the first expiration time, and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
The application provides a node server, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor, when executing the machine-executable instructions, performs the following:
Establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time;
And if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database.
The application provides a management server, includes: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor, when executing the machine-executable instructions, performs the following:
Acquiring data, and configuring a first expiration time and a second expiration time for the data;
sending a first message to a node server, wherein the first message carries the data, the first expiration time and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
Based on the above technical solution, in the embodiment of the present application, by setting a first expiration time and a second expiration time for data (taking data a as an example), when it is determined that data a has expired according to the first expiration time, but it is determined that data a has not expired according to the second expiration time, the node server does not delete data a, but continues to retain data a. Therefore, even if the node server cannot download the latest data and receives the request message for the data A sent by the client, the node server does not delete the data A, so that the data A can be returned to the client, the service interruption of the client is avoided, and the user experience is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments of the present application or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art according to the drawings of the embodiments of the present application.
Fig. 1 is a networking diagram of a CDN in the prior art;
FIG. 2 is a schematic diagram of an application scenario in an embodiment of the present application;
FIG. 3 is a flow chart of a data caching method in one embodiment of the present application;
FIG. 4 is a flow chart of a data caching method in another embodiment of the present application;
FIG. 5 is a flow chart of a data caching method in another embodiment of the present application;
FIG. 6 is a block diagram of a data caching apparatus according to an embodiment of the present application;
Fig. 7 is a configuration diagram of a data cache device according to another embodiment of the present application.
Detailed Description
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the examples and claims of this application, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein is meant to encompass any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in the embodiments of the present application to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. Depending on the context, moreover, the word "if" as used may be interpreted as "at … …" or "when … …" or "in response to a determination".
an embodiment of the present application provides a data caching method, which may be applied to a system including a node server, a management server, and a client, as shown in fig. 2, which is a schematic diagram of a system structure. The client may be an APP on a terminal device (e.g., a Personal Computer (PC), a notebook Computer, a mobile terminal, etc.), or may be a browser on the terminal device, and the type of the client is not limited, and all clients capable of accessing the node server and the management server are within the scope of the present application.
In one example, a management server may be deployed, the management server is used to store all data, and the data stored by the management server is not deleted due to expiration, but only the user may modify the data stored by the management server. For example, the management server stores data a, the user may modify data a to data B, or the user may delete data a, but data a is not deleted due to expiration.
In order to avoid the problem that the access amount of the management server is too large, which leads to the performance degradation of the management server, a plurality of node servers can be deployed for the management server, and the client can acquire data from the node servers without acquiring the data from the management server. In order to enable the node server to provide data to the client, the management server may send the data to the node server. Moreover, when the management server sends the data to the node server, the management server can also configure expiration time for the data, and send the corresponding relationship between the data and the expiration time to the node server, and the node server can store the corresponding relationship between the data and the expiration time.
Unlike the management server, the data stored by the node server is deleted due to expiration, but the user does not modify the data stored by the node server. For example, the management server sends the correspondence between the data a and the expiration time 1 to each node server, and each node server may store the correspondence between the data a and the expiration time 1. If the node server determines that the data A is expired according to the expiration time 1, the corresponding relation between the data A and the expiration time 1 is deleted, and the data A is requested from the management server again.
Further, if the data a stored locally by the management server does not change, the management server sends the corresponding relationship between the data a and the expiration time 1 to the node server again, and the node server may store the corresponding relationship between the data a and the expiration time 1. In addition, if the data a locally stored by the management server is modified to the data B by the user, the management server may transmit the correspondence relationship between the data B and the expiration time 1 to the node server, and the node server may store the correspondence relationship between the data B and the expiration time 1.
the reason why the management server configures the expiration time for the data a and sends the corresponding relationship between the data a and the expiration time to the node server is that: if the management server does not configure the expiration time for the data a, the node server always stores the data a after storing the data a, and even if the data a is modified to be the data B by the user on the management server, the node server cannot sense the condition and always provides the data a to the client, so that the data a provided to the client is wrong, and the service processing is abnormal.
In a conventional manner, the management server only configures an expiration time 1 for the data a, so that if the node server determines that the data a is expired according to the expiration time 1, the node server deletes the corresponding relationship between the data a and the expiration time 1, and re-requests the management server for the data a. Assuming a link failure between the node server and the management server, the node server cannot download the latest data from the management server. Thus, if the node server receives a request message for data a sent by the client, the node server cannot return data to the client, which causes service interruption of the client and affects user experience.
in view of the above discovery, in the embodiment of the present application, the management server may configure two expiration times for the data a, where the expiration times are expiration time 1 and expiration time 2, and the expiration time 2 is greater than the expiration time 1.
based on this, if the node server determines that the data a has expired according to the expiration time 1, the node server does not delete the corresponding relationship among the data a, the expiration time 1, and the expiration time 2, but requests the management server for the data a again. If a link between the node server and the management server fails, although the node server cannot download the latest data from the management server, the node server still stores the data a, so that if the node server receives a request message for the data a sent by the client, the node server can send the data a to the client, thereby avoiding service interruption of the client and improving user experience.
When the node server cannot download data from the management server, the link fault between the node server and the management server can be determined, an alarm log is sent out, and maintenance personnel can repair the link between the node server and the management server after receiving the alarm log. Therefore, during the period between expiration time 1 and expiration time 2, if the link repair is successful, the node server may download the latest data from the management server, so that the latest data can be downloaded before data a is deleted, and the node server can always provide data to the client. In the period between the expiration time 1 and the expiration time 2, if the link is not repaired successfully, the node server determines that the data a is expired according to the expiration time 2, and then deletes the corresponding relationship among the data a, the expiration time 1 and the expiration time 2.
In different application scenarios, the types and functions of the node server and the management server are different, and the node server and the management server are described below with reference to several specific application scenarios.
Application scenario 1: a CDN scenario. In a CDN scenario, the management server may be a CDN server, the node server may be a CDN node, and the data may include, but is not limited to, web page data, picture data, video data, audio data, text data, and the like, and the data type is not limited. In order to distinguish different data, each data has a unique data identifier, and the data identifier in the CDN scenario may be a URL (Uniform Resource Locator), which is not limited.
Application scenario 2: a DNS (Domain Name System) scenario. In the DNS scenario, the management server may be an authoritative DNS server, and the node server may be a Local DNS server, and the data may include, but is not limited to, domain name data, which may be a correspondence between a domain name and an IP address. To distinguish between different domain name data, each domain name data may have a unique data identifier, and the data identifier in the DNS scenario may be a domain name (e.g., www.aaa.com, etc.).
Application scenario 3: e-commerce scene. In the e-market scenario, the management server may be a database server, and the node server may be a cache server, and the data may include, but is not limited to, e-commerce data such as commodity information (commodity picture, commodity name, commodity price, commodity description information, commodity profile, etc.), and the type of the data is not limited. In order to distinguish different data, each data has a unique data identifier, and the data identifier in the e-market scene can be a commodity identifier, which is not limited.
of course, the above processes are only examples, and the application scenario is not limited in the embodiment of the present application.
In the above application scenario, referring to fig. 3, which is a flowchart of a data caching method provided in the embodiment of the present application, the method may be applied to a node server, and the method may include the following steps:
step 301, a cache database is established, wherein the cache database stores a first data item, the first data item includes data, a first expiration time and a second expiration time, and the second expiration time is greater than the first expiration time. For ease of distinction, each data item in the cache database may be referred to as a first data item.
In one example, the node server may establish a cache database, as shown in table 1, for an example of the cache database, each entry in the cache database may be referred to as a first data entry, and the first data entry may include data, a first expiration time and a second expiration time, and the second expiration time is greater than the first expiration time. In another example, referring to table 2, the first data item may further include a data identification and a data write time, and the data write time is a time when the first data item is written to the cache database.
TABLE 1
data of first expiration time Second expiration time
Data A1 5 minutes 30 minutes
Data A2 10 minutes 30 minutes
Data A3 1 hour 2 hours
TABLE 2
in one example, in order for the node server to establish the cache database shown in table 1 or table 2, the management server may first obtain locally stored data and configure a first expiration time and a second expiration time for the data. Then, the management server sends a first message to the node server, where the first message may carry data, a first expiration time, and a second expiration time. After receiving the first message, the node server may add a first data item to the cache database, and record the data carried by the first message, the first expiration time, and the second expiration time in the first data item, so as to obtain the cache database shown in table 1 or table 2.
For each piece of data locally stored by the management server, if the data is not sent to the node server, the management server sends a first message carrying the data to the node server, and if the data is sent to the node server, the management server does not send the first message carrying the data to the node server any more.
Before the management server sends the first message carrying the data to the node server, the management server may also configure a first expiration time and a second expiration time for the data. The management server may configure the first expiration time and the second expiration time according to actual needs, and the configuration manner is not limited as long as the second expiration time is greater than the first expiration time. The first expiration times of different data may be the same or different, and the second expiration times of different data may be the same or different.
For example, for data a1 locally stored by the management server, the management server configures a first expiration time of 5 minutes and a second expiration time of 30 minutes for data a1, and sends a first message carrying data a1, the first expiration time of 5 minutes and the second expiration time of 30 minutes to the node server, and after receiving the first message, the node server adds a first data item in the cache database, and records the data a1, the first expiration time of 5 minutes and the second expiration time of 30 minutes in the first data item, as shown in table 1.
In addition, the first message may also carry a data identifier 1, and after receiving the first message, the node server determines that the current time is 2017.6.2, 12:05:00 (i.e., data write time), and adds a first data item in the cache database, and then records the data identifier 1, the data a1, 2017.6.2, 12:05:00, the first expiration time of 5 minutes, and the second expiration time of 30 minutes in the first data item, as shown in table 2.
the processing method of the data a2 and the data A3 is the same as the processing method of the data a1, and is not described again.
Step 302, if it is determined that the first data item has expired according to the first expiration time and it is determined that the first data item has not expired according to the second expiration time, the first data item is retained in the cache database. In addition, if the first data item is determined to be unexpired according to the first expiration time, the first data item is reserved in the cache database. And if the first data item is determined to be expired according to the second expiration time, deleting the first data item from the cache database.
If the time difference between the current time and the data writing time is less than or equal to a first expiration time, determining that the first data item is not expired according to the first expiration time; or if the time difference between the current time and the data writing time is greater than a first expiration time and less than or equal to a second expiration time, determining that the first data item is expired according to the first expiration time, and determining that the first data item is not expired according to the second expiration time; or if the time difference between the current time and the data writing time is greater than the second expiration time, determining that the first data item has expired according to the second expiration time.
For example, for the first data item in table 2, if the current time is 2017.6.2, 12:08:00, the time difference between the current time and the data writing time is less than the first expiration time (5 minutes), so that it is determined that this first data item has not expired according to the first expiration time, and the cache of data a1 is valid. If the current time is 2017.6.2, 12:15:00, the time difference between the current time and the data writing time is greater than the first expiration time (5 minutes) and less than the second expiration time (30 minutes), so that the first data item is determined to have expired according to the first expiration time, but the first data item is determined not to have expired according to the second expiration time, and the cache of the data a1 is temporarily valid. If the current time is 2017.6.2, 12:40:00, the time difference between the current time and the data writing time is greater than the second expiration time (30 minutes), so that the first data item is determined to have expired according to the second expiration time, and the cache of the data A1 is invalidated.
In one example, if it is determined that the first data item has not expired based on the first expiration time, the second message need not be sent to the management server. If the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, a second message can be sent to the management server. Wherein the second message is a second message for requesting data in the first data item.
and if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, periodically sending the second message or sending the second message only once.
If the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, after the node server sends the second message to the management server, if a response message which is sent by the management server and aims at the second message is not received within the preset time, the node server continuously keeps the first data item in the cache database instead of deleting the first data item. If a response message aiming at the second message and sent by the management server is received within the preset time, the node server can delete the first data item from the cache database and does not reserve the first data item any more; then, the node server may further add a new data item in the cache database (for convenience of differentiation, this added new data item may be referred to as a second data item), and record the data carried by the response message, the first expiration time and the second expiration time in the second data item.
For example, for the first data item in table 2, if the current time is 2017.6.2, 12:15:00, it may be determined that this first data item has expired according to the first expiration time, but it is determined that this first data item has not expired according to the second expiration time, and therefore, the node server may send a second message to the management server, where this second message may carry a data identifier 1, which is used to request data corresponding to the data identifier 1.
If the link between the node server and the management server is not failed, the management server may receive the second message, and locally query the data corresponding to the data identifier 1, the first expiration time, and the second expiration time. And if the data A1 locally stored by the management server is not changed, the management server sends a response message carrying the data A1, the first expiration time of 5 minutes and the second expiration time of 30 minutes to the node server. If the data A1 stored locally by the management server is modified to be data B1 (the data identifier is still data identifier 1, and data B1 can be indexed), the management server sends a response message carrying the data B1, the first expiration time of 5 minutes and the second expiration time of 30 minutes to the node server. Based on this, the node server may receive the response message within the preset time, delete the first data item from the cache database, add the second data item to the cache database, and record the data carried in the response message, the first expiration time, and the second expiration time in the second data item (after the second data item is added to the cache database, the second data item is subsequently referred to as the first data item), as shown in table 3 or table 4.
TABLE 3
TABLE 4
data identification Data of Data write time First expiration time Second expiration time
Data identification 2 Data A2 2017.6.2,15:15:00 10 minutes 30 minutes
Data identification 3 data A3 2017.6.2,17:10:00 1 hour 2 hours
data identification 1 Data B1 2017.6.2,12:16:00 5 minutes 30 minutes
If the link between the node server and the management server fails, the management server cannot receive the second message, and does not send a response message to the node server, so that the node server does not receive the response message for the second message within the preset time, but still keeps the first data item in the cache database, as shown in table 2, until it is determined that the first data item has expired according to the second expiration time, and the node server deletes the first data item from the cache database, as shown in table 5.
TABLE 5
Data identification Data of Data write time First expiration time second expiration time
Data identification 2 data A2 2017.6.2,15:15:00 10 minutes 30 minutes
data identification 3 Data A3 2017.6.2,17:10:00 1 hour 2 hours
In an example, after the node server sends the second message to the management server, if a response message for the second message sent by the management server is not received within a preset time, the node server may further determine that a link between the node server and the management server is faulty, generate an alarm log for the link, and send the alarm log, such as a sending manner of a short message, a sending manner of a WeChat, or the like. Therefore, after receiving the alarm log, the maintenance personnel can repair the link between the node server and the management server.
in an example, based on each first data item stored in the cache database, when receiving a request message sent by a client, the node server may further query the cache database for a first data item matching the request message, and send data in the queried first data item to the client. For example, when receiving a request message sent by a client, if the request message carries a data identifier 1, the node server may query the cache database shown in table 2 through the data identifier 1 to obtain a first data item corresponding to the data identifier 1, and send data a1 in the first data item to the client.
Based on the above technical solution, in the embodiment of the application, by setting a first expiration time and a second expiration time for data, when it is determined that the data has expired according to the first expiration time, but it is determined that the data has not expired according to the second expiration time, the node server does not delete the data, but continues to retain the data. Therefore, even if the node server cannot download the latest data and receives the request message for the data sent by the client, the node server does not delete the data, so that the node server can return the data to the client, the service interruption of the client is avoided, and the use experience of the user is improved.
Based on the same application concept as the method described above, an embodiment of the present application provides a data caching method, which is a flowchart of the data caching method shown in fig. 4 and can be applied to a management server.
step 401, acquiring data, and configuring a first expiration time and a second expiration time for the data.
Step 402, sending a first message to a node server, where the first message may carry the data, the first expiration time, and the second expiration time; so that the node server adds a first data item in the cache database and records the data, the first expiration time and the second expiration time in the first data item.
in one example, the second expiration time is greater than the first expiration time.
The above technical solution is further described below with reference to specific application scenarios. In the application context, taking the processing procedure for the data a1 as an example, the processing procedure for other data is similar to the processing procedure for the data a1, and is not repeated. Fig. 5 is a schematic flow chart of the application scenario.
In step 501, the management server acquires data a1 locally, and configures a first expiration time and a second expiration time for the data a1, where the first expiration time is 5 minutes and the second expiration time is 30 minutes, for example.
Step 502, the management server sends a first message to each node server, where the first message may carry data identifier 1, data a1, a first expiration time of 5 minutes, and a second expiration time of 30 minutes.
In step 503, after receiving the first message, the node server determines the data write time 2017.6.2, 12:05:00, adds a data item in the cache database, and then records the data identifier 1, the data a1, 2017.6.2, 12:05:00, the first expiration time 5 minutes, and the second expiration time 30 minutes in the data item.
After a period of time, if the node server determines that the data item has expired according to the first expiration time, but determines that the data item has not expired according to the second expiration time, the node server sends a second message to the management server, and the second message is used for requesting data a1, step 504.
in step 505, the node server determines whether a response message for the second message sent by the management server is received within a preset time. If not, go to step 506; if so, step 507 is performed.
The node server continues to retain the data item in the cache database without deleting the data item, step 506.
In step 507, the node server deletes the data item from the cache database.
Step 508, the node server adds a new data item in the cache database, and records the data carried by the response message, the first expiration time and the second expiration time in the newly added data item.
in one example, based on each data item stored in the cache database, when receiving a request message sent by a client, the node server may query the cache database for a data item matching the request message, and send data in the queried data item to the client. For example, when receiving a request message sent by a client, if the request message carries a data identifier 1, the node server may query the cache database through the data identifier 1 to obtain a data item corresponding to the data identifier 1, and send data a1 in the data item to the client, where the node server successfully sends the data a1 to the client.
based on the same application concept as the method, the embodiment of the application also provides a data caching device which can be applied to a node server. As shown in fig. 6, which is a structural view of the apparatus, the apparatus includes:
An establishing module 601, configured to establish a cache database, where the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time; a processing module 602, configured to, when it is determined that the first data item has expired according to the first expiration time and it is determined that the first data item has not expired according to the second expiration time, retain the first data item in the cache database.
In an example, the establishing module 601 is further configured to receive a first message sent by a management server, where the first message carries the data, the first expiration time, and the second expiration time; adding the first data item in a cache database, and recording the data, the first expiration time and the second expiration time in the first data item.
the processing module 602, when the first data item is retained in the cache database, is specifically configured to: sending a second message for requesting data in the first data item to a management server; if a response message aiming at the second message and sent by the management server is not received within a preset time, reserving the first data item in the cache database;
The processing module 602 is further configured to, after sending the second message, delete the first data item from the cache database if a response message sent by the management server for the second message is received within a preset time; adding a second data item in a cache database, and recording the data, the first expiration time and the second expiration time carried by the response message into the second data item;
And if the response message aiming at the second message and sent by the management server is not received within the preset time, determining that the link between the node server and the management server is in fault, generating an alarm log aiming at the link, and sending the alarm log.
The processing module 602 is further configured to delete the first data item from the cache database when it is determined that the first data item has expired according to the second expiration time;
wherein the first data item further comprises a data write time, the data write time being a time at which the first data item was written to the cache database;
The processing module 602 is further configured to determine that the first data item is not expired according to the first expiration time when a time difference between the current time and the data writing time is less than or equal to the first expiration time; or when the time difference between the current time and the data writing time is greater than the first expiration time and less than or equal to the second expiration time, determining that the first data item is expired according to the first expiration time, and determining that the first data item is not expired according to the second expiration time; or when the time difference between the current time and the data writing time is greater than the second expiration time, determining that the first data item has expired according to the second expiration time.
Based on the same application concept as the method, the embodiment of the application also provides a data caching device which can be applied to a management server. As shown in fig. 7, which is a structural view of the apparatus, the apparatus includes:
An obtaining module 701, configured to obtain data, and configure a first expiration time and a second expiration time for the data; a sending module 702, configured to send a first message to a node server, where the first message carries the data, the first expiration time, and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
Based on the same application concept as the method, an embodiment of the present application further provides a node server, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor, when executing the machine-executable instructions, performs the following: establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time; and if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database.
Based on the same application concept as the method, an embodiment of the present application further provides a management server, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor, when executing the machine-executable instructions, performs the following: acquiring data, and configuring a first expiration time and a second expiration time for the data; sending a first message to a node server, wherein the first message carries the data, the first expiration time and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
Based on the same application concept as the method, the embodiment of the present application further provides a machine-readable storage medium, which can be applied to a node server, where the machine-readable storage medium has stored thereon several computer instructions, and when executed, the computer instructions perform the following processes: establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time; and if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database.
Based on the same application concept as the method, the embodiment of the present application further provides a machine-readable storage medium, which can be applied to a management server, where the machine-readable storage medium stores several computer instructions, and the computer instructions, when executed, perform the following processes:
Acquiring data, and configuring a first expiration time and a second expiration time for the data;
Sending a first message to a node server, wherein the first message carries the data, the first expiration time and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
the systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
as will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
furthermore, these computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
these computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
the above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (16)

1. A data caching method is applied to a node server, and the method comprises the following steps:
Establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time;
And if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database.
2. the method of claim 1, further comprising:
Receiving a first message sent by a management server, wherein the first message carries the data, the first expiration time and the second expiration time; adding the first data item in a cache database, and recording the data, the first expiration time and the second expiration time in the first data item.
3. The method of claim 1,
The process of retaining the first data item in the cache database specifically includes:
sending a second message for requesting data in the first data item to a management server;
And if a response message aiming at the second message and sent by the management server is not received within a preset time, reserving the first data item in the cache database.
4. The method of claim 3, wherein after sending the second message to the management server requesting the data in the first data item, the method further comprises:
If a response message aiming at the second message and sent by the management server is received within preset time, deleting the first data item from a cache database;
And adding a second data item in a cache database, and recording the data carried by the response message, the first expiration time and the second expiration time in the second data item.
5. The method of claim 3, wherein if a response message for the second message sent by the management server is not received within a preset time, the method further comprises:
Determining that a link between the node server and the management server is down;
And generating an alarm log aiming at the link and sending the alarm log.
6. The method of claim 1,
After said retaining said first data item in said cache database, said method further comprising:
and if a request message which is sent by a client and matched with the first data item is received, sending the data in the first data item to the client.
7. The method of claim 1,
After said retaining said first data item in said cache database, said method further comprising:
And if the first data item is determined to be expired according to the second expiration time, deleting the first data item from the cache database.
8. The method of claim 1 or 7, wherein the first data item further comprises a data write time, the data write time being a time at which the first data item was written to the cache database; if the time difference between the current time and the data writing time is less than or equal to the first expiration time, determining that the first data item is not expired according to the first expiration time; alternatively, the first and second electrodes may be,
if the time difference between the current time and the data writing time is greater than the first expiration time and less than or equal to the second expiration time, determining that the first data item is expired according to the first expiration time, and determining that the first data item is not expired according to the second expiration time; alternatively, the first and second electrodes may be,
And if the time difference between the current time and the data writing time is greater than the second expiration time, determining that the first data item is expired according to the second expiration time.
9. a data caching method is applied to a management server, and the method comprises the following steps:
Acquiring data, and configuring a first expiration time and a second expiration time for the data;
Sending a first message to a node server, wherein the first message carries the data, the first expiration time and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
10. a data caching apparatus, applied to a node server, the apparatus comprising:
The system comprises an establishing module, a data processing module and a data processing module, wherein the establishing module is used for establishing a cache database, and the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time;
and the processing module is used for reserving the first data item in the cache database when the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time.
11. The apparatus according to claim 10, wherein the establishing module is further configured to receive a first message sent by a management server, where the first message carries the data, the first expiration time, and the second expiration time; adding the first data item in a cache database, and recording the data, the first expiration time and the second expiration time in the first data item.
12. the apparatus of claim 10, wherein the processing module, when retaining the first data item in the cache database, is specifically configured to: sending a second message for requesting data in the first data item to a management server; if a response message aiming at the second message and sent by the management server is not received within a preset time, reserving the first data item in the cache database;
The establishing module is further configured to delete the first data item from the cache database after the second message is sent and if a response message for the second message sent by the management server is received within a preset time; adding a second data item in a cache database, and recording the data, the first expiration time and the second expiration time carried by the response message into the second data item;
And if the response message aiming at the second message and sent by the management server is not received within the preset time, determining that the link between the node server and the management server is in fault, generating an alarm log aiming at the link, and sending the alarm log.
13. The apparatus of claim 10,
The processing module is further configured to delete the first data item from the cache database when it is determined that the first data item has expired according to the second expiration time;
Wherein the first data item further comprises a data write time, the data write time being a time at which the first data item was written to the cache database;
The processing module is further configured to determine that the first data item is not expired according to the first expiration time when a time difference between the current time and the data writing time is less than or equal to the first expiration time; or when the time difference between the current time and the data writing time is greater than the first expiration time and less than or equal to the second expiration time, determining that the first data item is expired according to the first expiration time, and determining that the first data item is not expired according to the second expiration time; or when the time difference between the current time and the data writing time is greater than the second expiration time, determining that the first data item has expired according to the second expiration time.
14. a data caching apparatus, applied to a management server, the apparatus comprising:
The acquisition module is used for acquiring data and configuring first expiration time and second expiration time for the data;
a sending module, configured to send a first message to a node server, where the first message carries the data, the first expiration time, and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
15. A node server, comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor, when executing the machine-executable instructions, performs the following:
Establishing a cache database, wherein the cache database stores a first data item; the first data item comprises data, a first expiration time, and a second expiration time, the second expiration time being greater than the first expiration time;
And if the first data item is determined to be expired according to the first expiration time and the first data item is determined to be unexpired according to the second expiration time, keeping the first data item in the cache database.
16. A management server, comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor, when executing the machine-executable instructions, performs the following:
Acquiring data, and configuring a first expiration time and a second expiration time for the data;
Sending a first message to a node server, wherein the first message carries the data, the first expiration time and the second expiration time; so that the node server adds a first data item in a cache database and records the data, the first expiration time and the second expiration time into the first data item; wherein the second expiration time is greater than the first expiration time.
CN201810277589.8A 2018-03-30 2018-03-30 Data caching method and device and server Pending CN110555040A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810277589.8A CN110555040A (en) 2018-03-30 2018-03-30 Data caching method and device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810277589.8A CN110555040A (en) 2018-03-30 2018-03-30 Data caching method and device and server

Publications (1)

Publication Number Publication Date
CN110555040A true CN110555040A (en) 2019-12-10

Family

ID=68733764

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810277589.8A Pending CN110555040A (en) 2018-03-30 2018-03-30 Data caching method and device and server

Country Status (1)

Country Link
CN (1) CN110555040A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114531489A (en) * 2022-01-14 2022-05-24 北京字节跳动网络技术有限公司 Request response method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103246656A (en) * 2012-02-03 2013-08-14 宇龙计算机通信科技(深圳)有限公司 Method and server for generating static cached page
US20140279854A1 (en) * 2013-03-15 2014-09-18 Mckesson Financial Holdings Method and apparatus for selectively deleting cached records
CN104917829A (en) * 2015-05-27 2015-09-16 努比亚技术有限公司 Background data management method and device
CN107026758A (en) * 2017-04-14 2017-08-08 深信服科技股份有限公司 For the information processing method of CDN processing business and updates, information processing system and server
US20170353577A1 (en) * 2016-06-01 2017-12-07 Home Box Office, Inc. Cached data expiration and refresh

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103246656A (en) * 2012-02-03 2013-08-14 宇龙计算机通信科技(深圳)有限公司 Method and server for generating static cached page
US20140279854A1 (en) * 2013-03-15 2014-09-18 Mckesson Financial Holdings Method and apparatus for selectively deleting cached records
CN104917829A (en) * 2015-05-27 2015-09-16 努比亚技术有限公司 Background data management method and device
US20170353577A1 (en) * 2016-06-01 2017-12-07 Home Box Office, Inc. Cached data expiration and refresh
CN107026758A (en) * 2017-04-14 2017-08-08 深信服科技股份有限公司 For the information processing method of CDN processing business and updates, information processing system and server

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114531489A (en) * 2022-01-14 2022-05-24 北京字节跳动网络技术有限公司 Request response method and device

Similar Documents

Publication Publication Date Title
CN111970315A (en) Method, device and system for pushing message
US8756325B2 (en) Content management
US9549040B2 (en) First cache purge optimization handling of unavailable nodes
CN104580226A (en) Session data sharing system and method
CN105653198A (en) Data processing method and device
CN105450682B (en) Method, device and system for synchronously storing data and synchronizing data to client
CN109525678B (en) Block chain network system and corresponding node device discovery method
CN103455439A (en) Local caching device, system and method for providing content caching service
US20070265976A1 (en) License distribution in a packet data network
CN114598748A (en) Method, device and system for refreshing cache resources
CN111092934B (en) Method for updating client routing and storage medium
CN109873855A (en) A kind of resource acquiring method and system based on block chain network
CN110233902B (en) Session processing method and device, electronic equipment and machine-readable storage medium
CN110740155A (en) Request processing method and device in distributed system
CN110555040A (en) Data caching method and device and server
CN110581784B (en) Node health check method, device and equipment
CN108337280B (en) Resource updating method and device
CN110300140A (en) For the method for content update, refreshing client and network node in cloud distribution network
CN111586438B (en) Method, device and system for processing service data
CN112861031B (en) URL refreshing method, device and equipment in CDN and CDN node
CN110944037B (en) Method, computer device and storage medium for client cache change configuration
CN113238836A (en) Distributed content scheduling method, scheduling system and central server
CN114979025B (en) Resource refreshing method, device, equipment and readable storage medium
CN111125580A (en) Network resource acquisition method and device, electronic equipment and storage medium
CN114125060B (en) Resource caching method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40017548

Country of ref document: HK