WO2022206487A1 - 一种缓存对象更新方法、装置、设备及存储介质 - Google Patents

一种缓存对象更新方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2022206487A1
WO2022206487A1 PCT/CN2022/082248 CN2022082248W WO2022206487A1 WO 2022206487 A1 WO2022206487 A1 WO 2022206487A1 CN 2022082248 W CN2022082248 W CN 2022082248W WO 2022206487 A1 WO2022206487 A1 WO 2022206487A1
Authority
WO
WIPO (PCT)
Prior art keywords
update
cache
advance
cached
state information
Prior art date
Application number
PCT/CN2022/082248
Other languages
English (en)
French (fr)
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 贵州白山云科技股份有限公司
Publication of WO2022206487A1 publication Critical patent/WO2022206487A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the embodiments of the present disclosure relate to, but are not limited to, a cache object update method, apparatus, device, and storage medium.
  • the origin site caches objects in the cache server, and provides object query services for users through the cached objects.
  • Objects on the origin site are constantly updated, and accordingly, the objects cached in the cache server also need to be updated.
  • the related art provides an object update method, which sets a validity period for a cached object, and all requests for the object within the validity period will respond with the cached object. After the validity period expires, when the cache server receives the client's request for the object again, the cache server returns to the origin site to obtain the object, sends the object update request to the origin site, and re-determines the validity period of the object. If the object is not updated in the origin site, the origin site will inform the cache server that the object has not been updated, and the cache server will send the cached object to the client. If the object is updated in the origin site, the origin site sends the updated object to the cache server. The cache server replaces the currently cached object with the updated object, and sends the updated object to the client.
  • the above-mentioned related technology requests the source station to update the object after the validity period of the object expires. If the source station updates the object in advance before the validity period of the object expires, the client will obtain the expired content; otherwise, if the object is updated after the validity period expires, The client needs to wait for the edge server to return to the source to obtain the updated object, which leads to a longer response delay to the client.
  • the present disclosure provides a cache object update method, device, device and storage medium. Before the cache object becomes invalid, it is judged whether it needs to be updated in advance according to the relevant state information of the object, so as to avoid the expiration of the validity period of the object. Re-updating will cause too long a delay in responding to the client. It can provide the client with a more accurate cached object, update the cached object in a more timely manner, and provide a more intelligent way of judging whether to update, which can adapt to more and more complex network service environment.
  • a cache object update method is provided, applied to a cache server, including:
  • the determining whether to update the cache object in advance according to the relevant state information includes:
  • the relevant state information includes one or more of object state information corresponding to the cache object, client state information corresponding to the client, and system state information corresponding to the cache server The combination;
  • the determining the update condition corresponding to the cached object according to the preset configuration rule and the relevant state information includes:
  • the advance update rule that the cached object conforms to is determined from the preset configuration rules, and the advance update rule includes the advance time length of the cached object to be updated in advance;
  • An update condition corresponding to the cache object is generated according to the advance update rule and the validity period of the cache object.
  • the update condition includes: a time when an object acquisition request corresponding to the cached object is received within a range in advance of the validity period of the cached object, and/or, according to the cached object The validity period of the object and the advance update time determined by the advance duration included in the advance update rule.
  • determining, according to the relevant state information, an advance update rule that the cached object complies with from preset configuration rules including:
  • the advance duration corresponding to the object type is determined from a preset configuration rule.
  • the method further includes: if the advance time period is greater than a preset threshold, acquiring a periodic update rule from the preset configuration rule, where the periodic update rule is used to specify that every preset interval The unit duration is updated once;
  • the advance duration and the periodic update rule are determined as the advance update rule complied with by the cache object.
  • determining, according to the relevant state information, an advance update rule that the cached object complies with from preset configuration rules including:
  • the object identification information of the cached object included in the relevant state information determine the number of times the cached object is requested within a preset duration closest to the current time
  • the advance duration and expiration update rule corresponding to the preset number of times are obtained from the preset configuration rule, and the expiration update rule is used to specify that the object is updated at the end of the validity period ;
  • the advance duration and the expiration update rule are determined as the advance update rule complied with by the cache object.
  • updating the cached object and responding to the object acquisition request includes:
  • the acquiring the latest version object corresponding to the cached object from the origin server includes:
  • the latest version object corresponding to the version identifier returned by the source server is received.
  • the method further includes: updating the cache object again when the validity period of the cache object ends.
  • the updating the cache object includes:
  • a third status code sent by the origin server is received, where the third status code is used to indicate that the cached object in the origin server has not been updated.
  • a cache object update device comprising:
  • a receiving module configured to receive the object acquisition request sent by the client, and determine that the cached object corresponding to the object acquisition request exists and the validity period has not arrived;
  • an obtaining module configured to obtain the relevant state information corresponding to the cached object
  • a judgment module configured to judge whether to update the cache object in advance according to the relevant state information
  • An update module configured to update the cache object in advance if the judgment module determines that the cache object needs to be updated in advance, and respond to the object acquisition request.
  • an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the computer program to implement The method described in the first aspect above.
  • a computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the method described in the first aspect.
  • the cached object in the cache server before the validity period of the cached object in the cache server ends, it is judged whether the cached object needs to be updated in advance according to the relevant state information corresponding to the cached object. Updating the object causes the response time to the client to be too long, providing the client with a more accurate cached object, and the update of the cached object is more timely. According to the relevant state information of the cached object, a more intelligent way of judging whether to update the object is provided, which can adapt to the increasingly complex network service environment.
  • FIG. 1 is a flowchart of a method for updating a cached object according to an exemplary embodiment
  • FIG. 2 is a schematic diagram of a network architecture on which a cache object update method is shown according to an exemplary embodiment
  • FIG. 3 is a schematic flowchart of acquiring the latest version object from the origin server according to an exemplary embodiment
  • FIG. 4 is another flowchart of a method for updating a cached object according to an exemplary embodiment
  • FIG. 5 is a schematic structural diagram of an apparatus for updating a cache object according to an exemplary embodiment
  • FIG. 6 is a schematic structural diagram of an electronic device according to an exemplary embodiment
  • Fig. 7 is a schematic diagram of a storage medium according to an exemplary embodiment.
  • An embodiment of the present disclosure provides a cache object update method. Before the validity period of the cache object in the cache server expires, it is judged whether the cache object needs to be updated in advance according to the relevant state information corresponding to the cache object, and the cache can be updated in time when the cache object needs to be updated in advance. object to avoid too long a response delay to the client caused by updating the object after the validity period expires.
  • the embodiments of the present disclosure provide a more intelligent way of judging whether to update an object by improving the update conditions of the object, which can adapt to an increasingly complex network service environment, and integrate the system state of the cache server itself, the state of the client requesting the object, and the A combination of one or more of the states of the object itself, by combining these aspects to determine the strategy for the update of the object to be taken. It is beneficial to improve the cache server to provide more accurate cache objects for clients under different geographical location, load level, network environment, origin server status and other conditions, and the update of cache objects is more timely.
  • the object may be a string, a file or other data
  • the cache server may be a cache server in a CDN (Content Delivery Network), or a database or server with a cache function.
  • CDN Content Delivery Network
  • the method specifically includes the following steps:
  • Step 101 Receive an object acquisition request sent by the client, and determine that a cached object corresponding to the object acquisition request exists and the validity period has not reached.
  • the execution body of the embodiment of the present disclosure is a cache server.
  • the network architecture where the cache server is located is shown in FIG. 2 .
  • the network architecture includes a cache server, an origin server, and a client.
  • the client is connected to the cache server through the network
  • the cache server is connected to the cache server through
  • the network is connected to the origin server.
  • the origin server can be another cache server located one level above the cache server, or it can be the origin site as the object provider, such as the server of the website owner in the HTTP website.
  • the cache server obtains objects from the origin server and caches them, and the client obtains objects from the cache server.
  • the client When the user needs to view an object, the client sends an object acquisition request to the cache server, and the object acquisition request carries the client identification information, the object identification information corresponding to the requested object, and the like.
  • the client identification information may be a device identification corresponding to the client or an IP (Internet Protocol, Internet Protocol) address, or the like.
  • the object identification information can be the URL of the object (Uniform Resource Locator, Uniform Resource Locator), and the object identification information can also include protocol information, such as http://test.com/path/a.mp4 can be a object in mp4 format
  • the corresponding object identification information, and the protocol information is the HTTP protocol.
  • a large number of cache objects are stored in the cache server, and each cache object is stored corresponding to its own object identification information. And each cache object is set with a corresponding validity period.
  • the cache object is only valid within its own validity period, and the cache object can be used to provide services to the client. After the validity period expires, the cached object becomes invalid, and the cached object can no longer be used to provide services to the client.
  • the cache server After the cache server receives the above-mentioned object acquisition request sent by the client, it parses the object identification information from the object acquisition request, and queries the local cache whether there is a cache object corresponding to the object identification information. Whether the time has reached the validity period corresponding to the cached object, and if it is determined that the validity period of the cached object has not reached, then step 102 and subsequent operations are used to determine whether the cached object needs to be updated in advance.
  • the cache server If the cache server does not query the cache object corresponding to the object identification information in the local cache, or although the cache object corresponding to the object identification information is queried, but judges that the validity period corresponding to the cache object has arrived, it indicates that the current cache server has If there is no object that can respond to the client's object acquisition request, the cache server directly sends an object update request to the origin server, and the object update request carries the above-mentioned object identification information. After receiving the object update request, the origin server obtains the latest version object with the highest version among all objects corresponding to the object identification information, and sends the latest version object to the cache server. The cache server receives the latest version object, and sends the latest version object to the client.
  • the cache server also locally caches the object identification information and the corresponding relationship of the object of the latest version, and records the update time of the object of the latest version and sets the validity period for the object of the latest version. If an expired cache object corresponding to the object identification information is stored in the cache server, information such as the correspondence between the object identification information and the expired cache object and the validity period corresponding to the expired cache object are also deleted.
  • Step 102 Acquire relevant state information corresponding to the cache object.
  • the cache server determines that the cache object corresponding to the client's object acquisition request is stored locally, and determines that the validity period of the cache object has not reached, it acquires relevant state information corresponding to the cache object, and the relevant state information includes the cache object A combination of one or more of the corresponding object state information, the client state information corresponding to the client, and the system state information corresponding to the cache server.
  • the object status information corresponding to the cached object includes the last update time, valid status, validity period, object type, object cache requirements indicated by the source server, concurrency, status of the last update of the source server response, last updated attribute change status, A combination of one or more of various status information such as the number of requests.
  • the client state information includes client identification information, protocol information, request parameters, and the like.
  • the system state information corresponding to the cache server includes the geographic location of the cache server, system time, time zone, network environment or the current system state of the cache server, etc.
  • the current system state includes the load level of the cache server, the length of the waiting queue or other related software. status, etc.
  • Step 103 according to the relevant state information, determine whether to update the cache object in advance, and if so, perform step 104 .
  • a preset configuration rule is set in the cache server, and the preset configuration rule specifies that different status information corresponds to different advance update rules.
  • the preset configuration rule may specify that the object type is mp4 type The object is updated 5 minutes earlier, and so on.
  • the update condition corresponding to the cached object is determined according to the foregoing preset configuration rule and the obtained relevant state information.
  • an advance update rule complied with by the cache object is determined from a preset configuration rule, where the advance update rule at least includes an advance time period for updating the cache object in advance.
  • the update condition corresponding to the cache object is generated.
  • the update condition may be, if the time when the object acquisition request corresponding to the current cached object is received is within a range of an advance time period before the validity period of the cached object, the cached object is updated.
  • these objects are usually set with a longer validity period, and these objects with a large amount of data can be updated in advance for a longer period of time.
  • a very short advance time can be set, or even no advance update is performed.
  • the preset configuration rules specify the correspondence between some object types and the advance duration.
  • the preset configuration rules In the case of a long advance time, in order to avoid changes to the cached objects within the last advance time, the preset configuration rules also set that when the advance time is greater than the preset threshold, periodic updates are taken within the advance time.
  • the periodic update rule is used to specify that the update is performed every preset unit duration. Therefore, after determining the advance duration corresponding to the object type through the above method, if the advance duration is greater than the preset threshold, the periodic update rule is obtained from the preset configuration rule, and the advance duration and the periodic update rule are determined as the cache object The early update rules that are met.
  • the above preset unit duration may be 1 minute or 1.5 minutes.
  • the preset threshold can be 2 minutes, 3 minutes, or 5 minutes, etc.
  • the update condition corresponding to the cache object is generated according to the determined advance update rule and the validity period of the cache object. That is, the advance update time is determined according to the validity period of the cached object and the advance duration included in the advance update rule. According to the advance update time, the validity period and the periodic update rule, each update time of the periodic update is determined. The determined advance update time and each update time of periodic update are determined as update conditions corresponding to the cache object. Subsequently, by judging whether the current time belongs to the update time included in the update condition, it can be judged whether the cache object needs to be updated in advance.
  • mp4-type objects are generally used for video on demand, and larger objects have longer validity periods.
  • the relevant state information corresponding to the cache object a includes the object type mp4 of the cache object a, the validity period of 11:00, and the like.
  • the 5-minute advance time corresponding to the mp4 is obtained from the preset configuration rule, and it is determined to be updated every minute within 5 minutes.
  • the periodic update rule of 5 minutes in advance updated every one minute and the validity period of 11:00, it is determined that the update time corresponding to the cache object a includes 10:55, 10:56, 10:57, 10:58, 10: 59 and 11:00.
  • the time when the current object request is received is within the range of the time period ahead of the validity period of the cached object (for example, it can be 10:56:10), determine that the update condition corresponding to the cached object a is at the current system time (10:56:10 ), and/or, when the system time reaches these update times (10:57, 10:58, 10:59, and 11:00), the cache object a is updated actively or based on client requests. Subsequently, when it is determined that the system time reaches 10:57, 10:58, 10:59 or 11:00, the update operation is performed.
  • the cached object a corresponds to multiple update moments, if there are multiple requests within each period of the update moments, it only needs to be updated back to the source once.
  • m3u8 files are often used for live broadcasts.
  • the files are small and have a short valid time. Therefore, no update rules are set for m3u8 files in the preset configuration rules, and they can be updated when they expire. Or set the advance duration corresponding to the file type m3u8 to 0 in the preset configuration rules, and do not make any updates before the expiration of the m3u8 file.
  • the file identification information carried in the file acquisition request sent by the client is http://test.com/path/b.m3u8, it is determined that the cache object b is stored in the cache server, and the validity period of the cache object b has not reached.
  • the relevant state information corresponding to the cache object b includes the file type m3u8 of the cache object b, the validity period of 11:00, and the like.
  • the corresponding advance time is queried from the preset configuration rule, and it is found that the advance time corresponding to m3u8 is 0, or the advance time corresponding to m3u8 is not configured in the preset configuration rule, then it is not cached object b Set the update conditions, and then update the cache object b proactively or based on client requests after the system time reaches 11:00 (including 11:00).
  • some cached objects in the cache server are requested a large number of times in a short period of time.
  • the preset configuration rules are configured Shorter advance time, and in order to ensure that the objects are synchronized with the origin server within the advance time, it is also set in the preset configuration rules to update again when the validity period of these cached objects ends.
  • the cache server records the correspondence between the object identification information of each cached object and the requested times, and the requested times of the cached object only records the requested times within a preset duration closest to the current time.
  • the cache server After obtaining the relevant state information corresponding to the cached object, the cache server determines, according to the object identification information of the cached object included in the relevant state information, the number of times the cached object has been requested within a preset duration closest to the current time. If the requested number of times is greater than the preset number of times, the advance duration and expiration update rule corresponding to the preset number of times are obtained from the preset configuration rule, and the expiration update rule is used to specify that the object is updated when the validity period of the object ends.
  • the advance duration and the expiration update rule are determined as the advance update rule complied with by the cache object.
  • the above preset duration may be 10 seconds or 15 seconds.
  • the preset number of times can be 100 times, 200 times, and the like.
  • the update condition corresponding to the cache object is generated according to the determined advance update rule and the validity period of the cache object. That is, the advance update time is determined according to the validity period of the cached object and the advance duration included in the advance update rule. According to the advance update time, validity period and expiration update rule, each update time of the periodic update is determined. The determined advance update time and the expired update time are determined as update conditions corresponding to the cache object. Subsequently, by judging whether the current time belongs to the update time included in the update condition, it can be judged whether the cache object needs to be updated.
  • the advance time corresponding to a cached object that has been requested more than 100 times within 10 seconds is set to 10 seconds, and an expired update rule that is updated again at the end of the validity period of the cached object is set.
  • the object identification information carried in the object acquisition request sent by the client is http://test.com/a/body.css, it is determined that the cached object body is stored in the cache server, and the validity period of the cached object body has not been reached.
  • the relevant state information includes the object identification information http://test.com/a/body.css of the cache object body, the validity period of 11:00, and the like.
  • the object identification information http://test.com/a/body.css it is determined that the number of requests in the body of the cached object within 10s is 120, then the corresponding advance time is 10s and the expiration update rule is obtained from the preset configuration rules .
  • the expiration update rule and the validity period of 11:00 if the time when the current object request is received is within the scope of the advance period before the validity period of the cached object, for example, it can be 10:59:50 (or 10:59: 51), determine that the update time of the cache object body includes 10:59:50 (or 10:59:51) and 11:00. It is determined that the update condition corresponding to the cache object body is to update the cache object a when the system time reaches 10:59:50 (or 10:59:51) or 11:00. In the embodiment of the present disclosure, in each update time interval, only the first one of the received object requests is updated.
  • one or more of the object state information, client state information, and system state information of the cache server included in the relevant state information, for any information included in the relevant state information, are the same as the above-mentioned objects.
  • the types and the number of requests are similar, and the corresponding advance update rules can be configured in the preset configuration rules.
  • the cache server matches the pre-update rules that the cache object mostly conforms to from the preset configuration rules according to the relevant state information, and then determines the update condition corresponding to the cache object.
  • the update condition of the cache object is determined according to the system state information of the cache server included in the relevant state information.
  • the system status information of the cache server includes the system load level.
  • the cache server can obtain the current load value of the system in real time through the monitoring system, and determine whether the load value within a certain period of time closest to the current time is lower than the preset value, and the certain period of time can be is 10 minutes or 15 minutes, etc., the preset value can be 10 or 15, etc. If it is determined that the load value within a certain period of time is lower than the preset value, the advance update is enabled, and the frequency of update verification is increased to reduce the update delay of the cached object.
  • the cached object is updated at the time of the advance period before the validity period of the cached object arrives.
  • shorten the frequency of update verification that is, shorten the above-mentioned certain period of time. For example, before judging whether the load value within the nearest 15 minutes from the current time is lower than the preset value, after shortening the update verification frequency, determine whether the nearest 10 minutes from the current time or Whether the load value in a shorter period such as 8 minutes is lower than the preset value.
  • the above scheme of determining update conditions based on the load value may not be used, but the update conditions determined based on the object type and the number of requests are maintained and updated in advance.
  • the solution is conducive to the smooth playback of real-time streaming media.
  • the update condition may also be determined in combination with the load value of the system and a preset time period. For example, assuming that the preset time period is between 8:00 and 23:00, according to the load value, if the load value is lower than 10 in the last 15 minutes, the cached objects with a data volume greater than 10M will be updated and verified 5 minutes in advance. And keep checking at least once every minute when there is a request, reducing the update delay of large cache objects and the quality of service at the moment of expiration.
  • the cached objects with a data volume greater than 100M will be kept updated 5 minutes in advance, and there will be a checkup in the last minute when there is a request to reduce the update delay and expiration of larger cached objects.
  • Instant quality of service If the load value in the last 15 minutes is greater than or equal to 30, only the cached objects in mp4, TS or other real-time streaming media formats will be updated and verified in advance, and only necessary cached objects will be updated in advance as much as possible to reduce system pressure. Between 23:00 and 8:00 the next day, only the cached objects in the real-time streaming format are updated and checked in advance to reduce system pressure and reserve more resources for other tasks.
  • the update condition of the cached object may be determined according to the geographic location information.
  • whether the location of the cache server is located in a remote area can be determined according to the geographic location information.
  • full advance update verification is enabled, and the remote area can be set in the preset configuration rule.
  • the advance time corresponding to the geographic location information that is, all cached objects stored by the cache server in remote areas are updated in advance of the advance time corresponding to their geographic location information. In this way, the problem of delay in updating the cached object caused by the poor network environment in remote areas can be reduced, and the problem of poor service quality of the first request after the cached object expires can be avoided.
  • the update condition of the cache object may also be determined according to the network environment state. Specifically, when it is detected that the network quality of the upstream node is relatively good, the advance update can be reduced and the system load can be reduced. When the network quality is poor, in order to optimize the user experience, enable a wider range of advance updates, increase the advance update duration, and increase the frequency of update verification.
  • the update condition of the cached object requested by the client is determined by any of the above methods, it is determined whether the current cached object satisfies the update condition. That is, it is determined whether the current system time reaches the update time included in the update condition. If yes, it is determined that the cache object needs to be updated in advance, and then the operation of step 104 is performed. If not, it is determined that the cache object does not need to be updated in advance, and the currently stored cache object is directly sent to the client.
  • Step 104 Update the cached object in advance, and respond to the object acquisition request.
  • step 103 If it is determined in step 103 that the update condition of the cached object is currently satisfied, obtain the latest version object corresponding to the cached object from the origin server, replace the locally stored cached object with the latest version object; send the latest version object to the client end. That is, as shown in a of FIG. 3 , the cache server sends an object update request to the origin server, and the object update request includes the object identification information of the cache object. The latest version object corresponding to the object identification information returned by the source server is received, the cached object stored locally is replaced with the latest version object, and the latest version object is sent to the client. This ensures that the client obtains the latest version of the object and improves the accuracy of object acquisition.
  • the local cache object may be sent to the client.
  • the latest version object corresponding to the cache object is obtained from the source server through the local background, and the cache object stored locally is replaced with the latest version object. That is, as shown in b in FIG. 3 , the cache server sends the cache object to the client, and at the same time sends an object update request to the origin server in the background, and the object update request includes the object identification information of the cache object.
  • the latest version object corresponding to the object identification information returned by the source server is received, and the cached object stored locally is replaced with the latest version object. In this way, the client can be responded to as soon as possible, and the waiting time of the user can be shortened.
  • the origin server when the origin server responds to the object update request from the cache server, if there is an object of the latest version, it can send the object of the latest version and the first status code to the cache server, and the first status code is used to indicate the origin server. What is returned is the complete latest version object.
  • the first status code may be HTTP status code 200.
  • the origin server can also compare the latest version of the object with the above cached object, obtain part of the object content in the latest version of the object that is different from the above cached object, and send the obtained part of the object content and the second status code to the cache server.
  • the second status code may be HTTP status code 206.
  • the cache server After receiving the partial object content, the cache server generates the latest version object according to the partial object content and the cached object. If the object of the latest version does not exist in the source server, the source server may send a third status code to the cache server, and the third status code is used to indicate that the object in the source server has not been updated.
  • the third status code may be HTTP status code 304.
  • the cache server when the cache server requests to update the cache object in advance, the cache object in the origin server may not be updated. In this case, if the object is also obtained from the origin server and updated, network resources will be wasted , and increase the processing pressure of the source server.
  • an object update request corresponding to the cached object in the process of acquiring the latest version of the cached object from the origin server, an object update request corresponding to the cached object may also be generated in the embodiment of the present disclosure, and a cached object is added to the object update request. The version ID of the object. Then send the object update request to the origin server.
  • the origin server After the origin server receives the object update request, it compares the version ID with the version ID of the latest version object corresponding to the cached object stored in the origin server. If so, it indicates that the object has not been updated in the origin server, and sends the An unchanged indication message to the cache server. After receiving the indication message, the cache server sends the locally stored cache object to the client. If the source server compares the two version identifiers to be inconsistent, it indicates that the object has been updated in the source server, and sends the corresponding latest version object to the cache server. The cache server receives the latest version object corresponding to the version identifier returned by the source server, sends the latest version object to the client, and replaces the locally stored cache object with the latest version object.
  • the above-mentioned adding the version identifier of the cached object in the object update request may specifically add the version identifier in the message header of the object update request.
  • a version identifier can be added to the If-Modified-Since field or ETag field in the HTTP packet header, or other methods such as object version information that can be identified by the origin server can be used.
  • the last update time of the cached object may also be added to the object update request, so that the origin server can determine the version of the cached object according to the last update time.
  • S1 Receive an object acquisition request sent by the client.
  • S2 Determine whether a cache object corresponding to the object acquisition request is stored, if yes, execute step S3, if not, execute step S7.
  • S3 Determine whether the validity period of the cached object has reached, if not, go to step S4, and if so, go to step S7.
  • S4 Obtain relevant state information corresponding to the cache object.
  • S5 Determine the update condition corresponding to the cache object according to the relevant state information.
  • S6 Determine whether the cache object satisfies the update condition, if yes, go to step S7, if not, go to step S8.
  • S7 Obtain the latest version object corresponding to the cached object from the origin server, and send the latest version object to the client.
  • S8 Send the cached object to the client.
  • step S7 any one of the methods shown in a and b in FIG. 3 may be used, and the object acquisition request sent to the origin server may carry the version identifier of the cached object.
  • the present disclosure provides a more intelligent way of judging whether to update the object based on the relevant state information of the cached object, can adapt to the increasingly complex network service environment, and integrates the system state of the cache server itself, the state of the client requesting the object, and the object itself A combination of one or more of the states, and by combining these aspects, the strategy for the object update to be taken is determined. It is beneficial to improve the cache server's ability to provide clients with more accurate cache objects under different geographical location, load level, network environment, origin server status and other conditions, and to update cache objects in a more timely manner.
  • An embodiment of the present disclosure further provides an apparatus for updating a cache object, and the apparatus is configured to execute the method for updating a cache object provided by any of the foregoing embodiments.
  • the device includes:
  • the receiving module 501 is configured to receive the object acquisition request sent by the client, and determine that the cached object corresponding to the object acquisition request exists and the validity period has not arrived;
  • the obtaining module 502 is configured to obtain relevant state information corresponding to the cached object
  • the judgment module 503 is configured to judge whether to update the cache object in advance according to the relevant state information
  • the updating module 504 is configured to update the cached object in advance if the judgment module determines that the cached object needs to be updated in advance, and respond to the object acquisition request.
  • the judgment module 503 is configured to determine the update condition corresponding to the cached object according to the preset configuration rule and relevant state information; to judge whether the current cached object satisfies the update condition; if so, it is determined that the cached object needs to be updated in advance; if not, it is determined There is no need to update cache objects in advance.
  • the relevant state information includes one or more combinations of object state information corresponding to the cached object, client state information corresponding to the client, and system state information corresponding to the cache server;
  • the judgment module 503 is: It is set to determine the advance update rule that the cached object conforms to from the preset configuration rules according to the relevant status information.
  • the advance update rule includes the advance time period for the advance update of the cached object; according to the advance update rule and the validity period of the cached object, the corresponding cached object is generated. update conditions.
  • the update conditions include: the time when the object acquisition request corresponding to the cached object is received within the range of the advance time before the validity period of the cached object, and/or the advance update determined according to the validity period of the cached object and the advance time included in the advance update rule time.
  • the judging module 503 is configured to determine the advance duration corresponding to the object type from the preset configuration rule according to the object type of the cached object included in the relevant state information.
  • the judging module 503 is set to obtain periodic update rules from the preset configuration rules if the advance time is greater than the preset threshold, and the periodic update rules are used to stipulate that the update is once every preset unit time; the advance time and the periodic
  • the update rule determines the early update rule that the cached object conforms to.
  • the judgment module 503 is configured to determine the requested times of the cached object within the preset duration closest to the current time according to the object identification information of the cached object included in the relevant state information; Set the advance duration and expiration update rules corresponding to the preset times in the configuration rules, and the expiration update rules are used to specify the update at the end of the validity period of the object; the advance duration and expiration update rules are determined as the advance updates that the cached object conforms to rule.
  • the update module 504 is configured to obtain the latest version object corresponding to the cache object from the source server, and replace the locally stored cache object with the latest version object; send the latest version object to the client; or, send the cache object to the client;
  • the local background obtains the latest version object corresponding to the cache object from the origin server, and replaces the locally stored cache object with the latest version object.
  • the update module 504 is configured to generate an object update request corresponding to the cache object; add the version identifier of the cache object in the object update request; send the object update request to the source server; version object.
  • the updating module 504 is further configured to update the cached object again when the validity period of the cached object ends.
  • the update module 504 is further configured to receive a third status code sent by the source server if the latest version object corresponding to the cached object does not exist in the source server, where the third status code is used to indicate that the cached object in the source server has not been updated.
  • the cache object update apparatus provided by the above embodiments of the present disclosure and the cache object update method provided by the embodiments of the present disclosure are based on the same inventive concept, and have the same beneficial effects as the methods adopted, run or implemented by the stored applications.
  • Embodiments of the present disclosure further provide an electronic device to execute the above cache object update method.
  • FIG. 6 shows a schematic diagram of an electronic device provided by some embodiments of the present disclosure.
  • the electronic device 6 includes: a processor 600, a memory 601, a bus 602 and a communication interface 603, the processor 600, the communication interface 603 and the memory 601 are connected through the bus 602;
  • a computer program running on the processor 600 when the processor 600 runs the computer program, executes the cache object updating method provided by any of the foregoing embodiments of the present disclosure.
  • the memory 601 may include a high-speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM Random Access Memory
  • non-volatile memory such as at least one disk memory.
  • the communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 603 (which may be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
  • the bus 602 may be an ISA bus, a PCI bus, an EISA bus, or the like.
  • the bus can be divided into an address bus, a data bus, a control bus, and the like.
  • the memory 601 is used to store a program, and the processor 600 executes the program after receiving the execution instruction.
  • the cache object update method disclosed in any of the foregoing embodiments of the present disclosure can be applied to the processor 600 , or implemented by the processor 600 .
  • the processor 600 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above-mentioned method may be completed by an integrated logic circuit of hardware in the processor 600 or an instruction in the form of software.
  • the above-mentioned processor 600 can be a general-purpose processor, including a central processing unit (Central Processing Unit, referred to as CPU), a network processor (Network Processor, referred to as NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit. (ASIC), off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.
  • CPU Central Processing Unit
  • NP Network Processor
  • DSP digital signal processor
  • ASIC application-specific integrated circuit
  • FPGA off-the-shelf programmable gate array
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the steps of the methods disclosed in conjunction with the embodiments of the present disclosure may be directly embodied as executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
  • the software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art.
  • the storage medium is located in the memory 601, and the processor 600 reads the information in the memory 601, and completes the steps of the above method in combination with its hardware.
  • the electronic device provided by the embodiment of the present disclosure and the cache object update method provided by the embodiment of the present disclosure are based on the same inventive concept, and have the same beneficial effects as the method adopted, executed or implemented.
  • Embodiments of the present disclosure also provide a computer-readable storage medium corresponding to the cache object update method provided by the foregoing embodiments.
  • the computer-readable storage medium shown is an optical disc 30 on which a computer is stored.
  • a program ie, a program product
  • examples of the computer-readable storage medium may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random Access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media will not be repeated here.
  • PRAM phase-change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM random Access memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • flash memory or other optical and magnetic storage media will not be repeated here.
  • the computer-readable storage medium provided by the above-mentioned embodiments of the present disclosure and the cache object updating method provided by the embodiments of the present disclosure are based on the same inventive concept, and have the same beneficial effects as the methods adopted, run or implemented by the stored applications.
  • the cached object in the cache server before the validity period of the cached object in the cache server ends, it is judged whether the cached object needs to be updated in advance according to the relevant state information corresponding to the cached object. Updating the object causes the response time to the client to be too long, providing the client with a more accurate cached object, and the update of the cached object is more timely. According to the relevant state information of the cached object, a more intelligent way of judging whether to update the object is provided, which can adapt to the increasingly complex network service environment.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本公开是关于一种缓存对象更新方法、装置、设备及存储介质,该方法包括:接收客户端发送的对象获取请求,确定对象获取请求对应的缓存对象存在且有效期未到达;获取缓存对象的相关状态信息;根据相关状态信息,判断是否提前更新缓存对象;若是,则提前更新缓存对象,及对对象获取请求进行响应。

Description

一种缓存对象更新方法、装置、设备及存储介质
本公开基于2021年03月30日提交中国专利局、申请号为202110340680.1,发明名称为“一种缓存对象更新方法、装置、设备及存储介质”的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本公开作为参考。
技术领域
本公开实施例涉及但不限于一种缓存对象更新方法、装置、设备及存储介质。
背景技术
目前,很多网络通信场景中设置有缓存服务器,源站将对象缓存在缓存服务器中,通过缓存的对象为用户提供对象查询服务。源站的对象会不断更新,相应地也需要对缓存服务器中缓存的对象进行更新。
相关技术中提供了一种对象更新方法,该方法为缓存的对象设置了有效期,在该有效期内所有针对该对象的请求都会使用缓存的该对象进行响应。在该有效期结束之后,缓存服务器再次接收到客户端对该对象的请求时,缓存服务器再回源站获取该对象,缓存服务器发送对象更新请求给源站,并重新确定该对象的有效期。若在源站中未更新该对象,则源站会告知缓存服务器该对象未更新,缓存服务器将缓存的该对象发送给客户端。若在源站中更新了该对象,则源站将更新后的对象发送给缓存服务器。缓存服务器将当前缓存的该对象替换为更新后的对象,并将更新后的对象发送给客户端。
上述相关技术在对象的有效期结束后才向源站请求更新对象,若源站在对象有效期结束之前提前更新了对象,客户端就会获得已过期的内容;反之,若在有效期结束再更新对象,客户端需要等待边缘服务器回源获取更新后的对象,这就导致对客户端的响应时延变长。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
为克服相关技术中存在的问题,本公开提供一种缓存对象更新方法、装置、设备及存储介质,在缓存对象失效前,依据对象的相关状态信息判断是否需提前更新,避免在对象过了有效期后再更新造成对客户端响应的时延太长,能为客户端提供更精确的缓存对象,缓存对象的更新更加及时,提供了更智能的判断是否更新的方式,能适应越来越复杂的网络服务环境。
根据本公开的第一方面,提供一种缓存对象更新方法,应用于缓存服务器,包括:
接收客户端发送的对象获取请求,确定所述对象获取请求对应的缓存对象存在且有效期未到达;
获取所述缓存对象对应的相关状态信息;
根据所述相关状态信息,判断是否提前更新所述缓存对象;
如果是,则提前更新所述缓存对象,以及对所述对象获取请求进行响应。
在一些示例性的实施例中,所述根据所述相关状态信息,判断是否提前更新所述缓存对象,包括:
根据预设配置规则和所述相关状态信息,确定所述缓存对象对应的更新条件;
判断当前所述缓存对象是否满足所述更新条件;
如果是,则确定需要提前更新所述缓存对象;
如果否,则确定不需要提前更新所述缓存对象。
在一些示例性的实施例中,所述相关状态信息包括所述缓存对象对应的对象状态信息、所述客户端对应的客户端状态信息、缓存服务器对应的系统状态信息中的一种或多种的组合;
所述根据预设配置规则和所述相关状态信息,确定所述缓存对象对应的更新条件,包括:
根据所述相关状态信息,从预设配置规则中确定出所述缓存对象所符合的提前更新规则,所述提前更新规则包括提前更新所述缓存对象的提前时长;
根据所述提前更新规则和所述缓存对象的有效期,生成所述缓存对象对应的更新条件。
在一些示例性的实施例中,所述更新条件包括:位于所述缓存对象的有效期之前提前时长的范围内接收到所述缓存对象对应的对象获取请求的时刻,和/或,根据所述缓存对象的有效期及所述提前更新规则中包括的提前时长所确定的提前更新时刻。
在一些示例性的实施例中,所述根据所述相关状态信息,从预设配置规则中确定出所述缓存对象所符合的提前更新规则,包括:
根据所述相关状态信息包括的所述缓存对象的对象类型,从预设配置规则中确定出所述对象类型对应的提前时长。
在一些示例性的实施例中,还包括:若所述提前时长大于预设阈值,则从所述预设配置规则中获取周期性更新规则,所述周期性更新规则用于规定每隔预设单位时长更新一次;
将所述提前时长及所述周期性更新规则确定为所述缓存对象所符合的提前更新规则。
在一些示例性的实施例中,所述根据所述相关状态信息,从预设配置规则中确定出所述缓存对象所符合的提前更新规则,包括:
根据所述相关状态信息包括的所述缓存对象的对象标识信息,确定所述缓存对象在距离当前时间最近的预设时长内的被请求次数;
若所述被请求次数大于预设次数,则从预设配置规则中获取所述预设次数对应的提前时长及到期更新规则,所述到期更新规则用于规定在对象的有效期结束时更新;
将所述提前时长及所述到期更新规则确定为所述缓存对象所符合的提前更新规则。
在一些示例性的实施例中,所述更新所述缓存对象,以及对所述对象获取请求进行响应,包括:
从源服务器获取所述缓存对象对应的最新版本对象,将本地存储的所述缓存对象替换为所述最新版本对象;发送所述最新版本对象给所述客户端;或者,
发送所述缓存对象给所述客户端;同时通过本地后台从源服务器获取所述缓存对象对应的最新版本对象,将本地存储的所述缓存对象替换为所述最新版本对象。
在一些示例性的实施例中,所述从源服务器获取所述缓存对象对应的最新版本对象,包括:
生成所述缓存对象对应的对象更新请求;
在所述对象更新请求中添加所述缓存对象的版本标识;
发送所述对象更新请求给源服务器;
接收所述源服务器返回的所述版本标识对应的最新版本对象。
在一些示例性的实施例中,还包括:在所述缓存对象的有效期结束时再次更新所述缓存对象。
在一些示例性的实施例中,所述更新所述缓存对象包括:
若源服务器中不存在所述缓存对象对应的最新版本对象,则接收所述源服务器发送的第三状态码,所述第三状态码用于表示所述源服务器中所述缓存对象尚未更新。
根据本公开的第二方面,提供一种缓存对象更新装置,包括:
接收模块,设置为接收客户端发送的对象获取请求,确定所述对象获取请求对应的缓存对象存在且有效期未到达;
获取模块,设置为获取所述缓存对象对应的相关状态信息;
判断模块,设置为根据所述相关状态信息,判断是否提前更新所述缓存对象;
更新模块,设置为如果所述判断模块判断出需要提前更新所述缓存对象,则提前更新所述缓存对象,以及对所述对象获取请求进行响应。
根据本公开的第三方面,提供一种电子设备,包括存储器、处理器及存储在所述存储器 上并可在所述处理器上运行的计算机程序,所述处理器运行所述计算机程序以实现上述第一方面所述的方法。
根据本公开的第四方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述程序被处理器执行实现上述第一方面所述的方法。
本公开提供的技术方案,至少具有如下技术效果或优点:
在本公开中,在缓存服务器中缓存对象的有效期结束之前,依据缓存对象对应的相关状态信息来判断是否需要提前更新缓存对象,当需要提前更新时能够及时更新缓存对象,避免在有效期结束之后再更新对象造成对客户端的响应时延太长,为客户端提供更精确的缓存对象,缓存对象的更新更加及时。依据缓存对象的相关状态信息,提供了更智能的判断是否更新对象的方式,能够适应越来越复杂的网络服务环境。
在阅读并理解了附图和详细描述后,可以明白其他方面。
附图说明
通过阅读下文实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出实施方式的目的,而并不认为是对本申请的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1是根据一示例性实施例示出的一种缓存对象更新方法的流程图;
图2是根据一示例性实施例示出的缓存对象更新方法所基于的网络架构的示意图;
图3是根据一示例性实施例示出的从源服务器获取最新版本对象的流程示意图;
图4是根据一示例性实施例示出的一种缓存对象更新方法的另一流程图;
图5是根据一示例性实施例示出的一种缓存对象更新装置的结构示意图;
图6是根据一示例性实施例示出的一种电子设备的结构示意图;
图7是根据一示例性实施例示出的一种存储介质的示意图。
具体实施方式
下面将参照附图更详细地描述本公开的示例性实施方式。虽然附图中显示了本公开的示例性实施方式,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施方式所限制。相反,提供这些实施方式是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
需要注意的是,除非另有说明,本公开使用的技术术语或者科学术语应当为本公开所属 领域技术人员所理解的通常意义。
下面结合附图来描述根据本公开实施例提出的一种缓存对象更新方法、装置、设备及存储介质。
本公开实施例提供了一种缓存对象更新方法,在缓存服务器中缓存对象的有效期结束之前,依据缓存对象对应的相关状态信息来判断是否需要提前更新缓存对象,当需要提前更新时能够及时更新缓存对象,避免在有效期结束之后再更新对象造成对客户端的响应时延太长。而且本公开实施例通过改进对象的更新条件,提供了更智能的判断是否更新对象的方式,能够适应越来越复杂的网络服务环境,综合缓存服务器自身的系统状态、请求对象的客户端的状态以及对象本身的状态中的一种或多种的组合,通过综合这些方面来确定所采取的对象更新的策略。有利于提高缓存服务器在不同地理位置、负载水平、网络环境、源服务器状态等条件下,为客户端提供更精确的缓存对象,缓存对象的更新更加及时。
在本公开的实施例中,对象可以是一个字符串、文件或其他数据,缓存服务器可以是CDN(Content Delivery Network,内容分发网络)中的缓存服务器,也可以是具有缓存功能的数据库或者服务器。
参见图1,该方法具体包括以下步骤:
步骤101:接收客户端发送的对象获取请求,确定该对象获取请求对应的缓存对象存在且有效期未到达。
本公开实施例的执行主体为缓存服务器,缓存服务器所在的网络架构如图2所示,在该网络架构中包括缓存服务器、源服务器和客户端,客户端通过网络与缓存服务器连接,缓存服务器通过网络与源服务器连接。源服务器可以为位于缓存服务器上一级的另一个缓存服务器,也可以为作为对象提供方的源站,如HTTP网站中的网站所有者的服务器。在该网络架构中,缓存服务器从源服务器中获取对象并缓存,客户端从缓存服务器中获取对象。
当用户需要查看某个对象时,通过客户端发送对象获取请求给缓存服务器,该对象获取请求中携带客户端标识信息、所请求的对象对应的对象标识信息等。其中,客户端标识信息可以为客户端对应的设备标识或IP(Internet Protocol,网际互联协议)地址等。对象标识信息可以为对象的URL(Uniform Resource Locator,统一资源定位器),对象标识信息中也可以包括协议信息,如http://test.com/path/a.mp4可以为mp4格式的a对象对应的对象标识信息,协议信息为HTTP协议。
缓存服务器中存储有大量的缓存对象,每个缓存对象都与各自的对象标识信息对应存储。且每个缓存对象都设置有对应的有效期,缓存对象只有在自己的有效期内才有效,才可以使 用该缓存对象为客户端提供服务。而超过有效期之后该缓存对象失效,不能再利用该缓存对象为客户端提供服务。缓存服务器接收到客户端发送的上述对象获取请求后,从该对象获取请求中解析出对象标识信息,从本地缓存中查询是否存在该对象标识信息对应的缓存对象,如果存在,则判断当前的系统时间是否到达该缓存对象对应的有效期,如果判断出该缓存对象的有效期未到达,则通过步骤102及后续的操作判断当前是否需要提前更新该缓存对象。
如果缓存服务器未在本地缓存中查询到该对象标识信息对应的缓存对象,或者虽然查询到了该对象标识信息对应的缓存对象,但判断出该缓存对象对应的有效期已到达,则表明当前缓存服务器中不存在能够对客户端的对象获取请求进行响应的对象,缓存服务器直接发送对象更新请求给源服务器,该对象更新请求中携带上述对象标识信息。源服务器接收到该对象更新请求后,获取该对象标识信息对应的所有对象中版本最高的最新版本对象,发送该最新版本对象给缓存服务器。缓存服务器接收该最新版本对象,将该最新版本对象发送给客户端。缓存服务器还在本地缓存该对象标识信息及该最新版本对象的对应关系,并记录该最新版本对象的更新时间以及为该最新版本对象设置有效期。若缓存服务器中存储有该对象标识信息对应的过期的缓存对象,则还删除该对象标识信息与过期的缓存对象的对应关系及过期的缓存对象对应的有效期等信息。
步骤102:获取该缓存对象对应的相关状态信息。
若步骤101中缓存服务器确定出本地存储有客户端的对象获取请求对应的缓存对象,且确定该缓存对象的有效期未到达,则获取该缓存对象对应的相关状态信息,该相关状态信息包括该缓存对象对应的对象状态信息、该客户端对应的客户端状态信息、缓存服务器对应的系统状态信息中的一种或多种的组合。
其中,缓存对象对应的对象状态信息包括最后更新时间、有效状态、有效期、对象类型、源服务器指示的对象缓存要求、并发情况、上一次更新源服务器响应的状态、上一次更新的属性变更状况、被请求次数等多种状态信息中的一种或多种的组合。客户端状态信息包括客户端标识信息、协议信息、请求参数等。缓存服务器对应的系统状态信息包括缓存服务器所处的地理位置、系统时间、所在时区、网络环境或缓存服务器的当前系统状态等,当前系统状态包括缓存服务器的负载水平、等待队列长度或其他相关软件的状态等。
步骤103:根据该相关状态信息,判断是否提前更新该缓存对象,如果是,则执行步骤104。
在本公开实施例中,缓存服务器中设置有预设配置规则,该预设配置规则中规定了不同的状态信息对应采取不同的提前更新规则,如预设配置规则中可以规定对象类型为mp4类型 的对象提前5分钟更新,等等。
通过步骤102获得该缓存对象对应的相关状态信息后,根据上述预设配置规则和获取的相关状态信息,确定该缓存对象对应的更新条件。在一些示例性的实施例中,根据获取的相关状态信息,从预设配置规则中确定出该缓存对象所符合的提前更新规则,该提前更新规则至少包括提前更新该缓存对象的提前时长。根据确定出的提前更新规则和该缓存对象的有效期,生成该缓存对象对应的更新条件。
在本公开的一个实施例中,更新条件可以是,若接收到当前缓存对象对应的对象获取请求的时刻位于该缓存对象的有效期之前提前时长的范围内,则更新该缓存对象。
在本公开的一些实施例中,由于有的对象类型的对象数据量较大,这些对象通常设置有较长的有效期,可以提前较长时间更新这些数据量较大的对象。而对于数据量较小且有效期很短的对象,则可以设置很短的提前时长,甚至不进行提前更新。预设配置规则中规定了一些对象类型与提前时长的对应关系。缓存服务器获取到缓存对象对应的相关状态信息后,从该相关状态信息中提取该缓存对象的对象类型,从预设配置规则中确定出该对象类型对应的提前时长。
在提前时长较长的情况下,为了避免在最后的该提前时长内缓存对象发生变更,预设配置规则中还设定了在提前时长大于预设阈值时,在该提前时长内采取周期性更新规则,该周期性更新规则用于规定每隔预设单位时长更新一次。因此通过上述方式确定出对象类型对应的提前时长后,若该提前时长大于预设阈值,则从预设配置规则中获取周期性更新规则,将该提前时长及周期性更新规则确定为该缓存对象所符合的提前更新规则。上述预设单位时长可以为1分钟或1.5分钟等。预设阈值可以为2分钟、3分钟或5分钟等。
通过上述方式确定出该缓存对象对应的提前更新规则后,根据确定出的提前更新规则和该缓存对象的有效期,生成该缓存对象对应的更新条件。即根据该缓存对象的有效期及提前更新规则中包括的提前时长,确定提前更新时刻。根据该提前更新时刻、有效期及周期性更新规则,确定周期性更新的每个更新时刻。将确定出来的提前更新时刻以及周期性更新的每个更新时刻确定为该缓存对象对应的更新条件。后续通过判断当前时间是否属于更新条件包括的更新时刻,即可判断出是否需要提前更新缓存对象。
对于上述根据缓存对象的对象类型、有效期等信息来确定更新条件的方式,下面以具体实例进行说明。例如,mp4类型的对象一般用于视频点播,对象较大具有较长的有效期。在预设配置规则中配置对象类型MP4对应的提前时长为5分钟,并设置提前时长大于等于5分钟时每隔一分钟更新一次。当客户端发送的对象获取请求中携带的对象标识信息为 http://test.com/path/a.mp4时,在判断缓存服务器中存储有缓存对象a,且缓存对象a的有效期未到达后,获取缓存对象a对应的相关状态信息,该相关状态信息包括缓存对象a的对象类型mp4、有效期11:00等。根据所请求的对象类型mp4,从预设配置规则中获取mp4对应的提前时长5分钟以及确定在5分钟内每隔一分钟更新一次。根据提前时长5分钟、每隔一分钟更新一次的周期性更新规则以及有效期11:00,确定缓存对象a对应的更新时刻包括10:55、10:56、10:57、10:58、10:59及11:00。若接收到当前对象请求的时刻位于缓存对象的有效期之前提前时长的范围内(例如可以是10:56:10),确定该缓存对象a对应的更新条件为在当前系统时间(10:56:10),和/或,系统时间到达这些更新时刻(10:57、10:58、10:59及11:00)时主动或基于客户端请求更新缓存对象a。后续当判断出系统时间到达10:57、10:58、10:59或11:00时均进行更新操作。
在一些示例性的实施例中,当缓存对象a对应多个更新时刻,在更新时刻的每个时段内如有多次请求,只需要回源更新一次。
与mp4文件不同,m3u8文件经常用于直播,文件较小且具有较短的有效时间,因此在预设配置规则中不对m3u8类文件设置任何更新规则,在失效时做更新即可。或者在预设配置规则中设置文件类型m3u8对应的提前时长为0,在m3u8文件有效期结束前不做任何更新。当客户端发送的文件获取请求中携带的文件标识信息为http://test.com/path/b.m3u8时,在判断缓存服务器中存储有缓存对象b,且缓存对象b的有效期未到达后,获取缓存对象b对应的相关状态信息,该相关状态信息包括缓存对象b的文件类型m3u8、有效期11:00等。根据所请求的文件类型m3u8,从预设配置规则中查询对应的提前时长,得知m3u8对应的提前时长为0,或者预设配置规则中未配置m3u8对应的提前时长,则不为缓存对象b设置更新条件,后续当系统时间到达11:00之后(包括11:00)再主动或基于客户端请求更新缓存对象b。
在本公开的另一些实施例中,缓存服务器中有些缓存对象短时间内被请求次数很大,为了减少客户端请求这些缓存对象的等待时间,对于这些缓存对象,在预设配置规则中配置了较短的提前时长,且为了保证对象在该提前时长内与源服务器同步,还在预设配置规则中设定在这些缓存对象的有效期结束时再次更新。在一些示例性的实施例中,缓存服务器记录每个缓存对象的对象标识信息与被请求次数的对应关系,缓存对象的被请求次数仅记录距离当前时间最近的预设时长内的被请求次数。缓存服务器获得缓存对象对应的相关状态信息后,根据相关状态信息包括的缓存对象的对象标识信息,确定该缓存对象在距离当前时间最近的预设时长内的被请求次数。若该被请求次数大于预设次数,则从预设配置规则中获取该预设次数对应的提前时长及到期更新规则,到期更新规则用于规定在对象的有效期结束时更新。 将该提前时长及到期更新规则确定为该缓存对象所符合的提前更新规则。上述预设时长可以为10秒或15秒等。预设次数可以为100次、200次等。
通过上述方式确定出该缓存对象对应的提前更新规则后,根据确定出的提前更新规则和该缓存对象的有效期,生成该缓存对象对应的更新条件。即根据该缓存对象的有效期及提前更新规则中包括的提前时长,确定提前更新时刻。根据该提前更新时刻、有效期及到期更新规则,确定周期性更新的每个更新时刻。将确定出来的提前更新时刻以及到期更新的时刻确定为该缓存对象对应的更新条件。后续通过判断当前时间是否属于更新条件包括的更新时刻,即可判断出是否需要更新缓存对象。
对于上述根据缓存对象的被请求次数、有效期等信息来确定更新条件的方式,下面以具体实例进行说明。例如,预设配置规则中设置了10秒内被请求次数超过100次的缓存对象对应的提前时长为10秒,且设置在该缓存对象的有效期结束时再次更新的过期更新规则。当客户端发送的对象获取请求中携带的对象标识信息为http://test.com/a/body.css时,在判断缓存服务器中存储有缓存对象body,且缓存对象body的有效期未到达后,获取缓存对象body对应的相关状态信息,该相关状态信息包括缓存对象body的对象标识信息http://test.com/a/body.css、有效期11:00等。根据对象标识信息http://test.com/a/body.css确定10s内缓存对象body内请求次数为120次,则从预设配置规则中获取对应的提前时长为10s以及获取到期更新规则。根据该提前时长10s、到期更新规则及有效期11:00,若接收到当前对象请求的时刻位于缓存对象的有效期之前提前时长的范围内,例如可以是10:59:50(或10:59:51),确定缓存对象body的更新时刻包括10:59:50(或10:59:51)和11:00。确定该缓存对象body对应的更新条件为系统时间到达10:59:50(或10:59:51)或11:00时更新缓存对象a。在本公开实施例中,在每一更新时间间隔内,只对接收到的该对象请求中的第一个进行更新。
在本公开实施例中,相关状态信息中包括的对象状态信息、客户端状态信息以及缓存服务器的系统状态信息的一种或多种,对于相关状态信息中包括的任一信息,都与上述对象类型及被请求次数相似,都可以在预设配置规则中配置相应的提前更新规则。缓存服务器根据相关状态信息从预设配置规则中匹配出该缓存对象多符合的提前更新规则,进而确定出该缓存对象对应的更新条件。
作为一种示例,对于根据相关状态信息包括的缓存服务器的系统状态信息来确定缓存对象的更新条件。例如,缓存服务器的系统状态信息包括系统负载水平,缓存服务器可以通过监控系统实时获取系统当前的负载数值,并判断距离当前时间最近的一定时长内的负载数值 是否低于预设数值,一定时长可以为10分钟或15分钟等,预设数值可以为10或15等。若判断出一定时长内的负载数值低于预设数值,则开启提前更新,并提高更新校验的频次,降低缓存对象的更新时延。如可以在预设配置规则中配置一定时长内的负载数值低于预设数值对应的提前时长,在缓存对象的有效期到达前该提前时长的时刻更新缓存对象。以及缩短更新校验的频次,即缩短上述一定时长,如之前判断距离当前时间最近的15分钟内的负载数值是否低于预设数值,缩短更新校验频次后判断距离当前时间最近的10分钟或8分钟等更短时长内的负载数值是否低于预设数值。
对于对象类型为mp4、TS(Transport Stream,传输流)等流媒体缓存对象,可以不采用上述依据负载数值来确定更新条件的方案,保持上述依据对象类型、被请求次数等确定更新条件并提前更新的方案,有利于实时流媒体的流畅播放。
在本公开的另一些实施例中,也可以结合系统的负载数值和预先设置的时间段来确定更新条件。例如,假设预先设置的时间段为8:00到23:00之间,根据负载数值,如果最近15分钟内负载数值低于10,则保持数据量大于10M的缓存对象提前5分钟更新校验,并保持有请求时每分钟至少一次校验,减少较大缓存对象的更新延迟和过期瞬间服务的质量。如果最近15分钟内负载数值低于30,则保持数据量大于100M的缓存对象提前5分钟更新校验,并保持有请求时最后一分钟有一次校验,减少更大缓存对象的更新延迟和过期瞬间服务的质量。如果最近15分钟内负载数值大于等于30,则只对mp4、TS或其他实时流媒体格式的缓存对象做提前更新校验,尽可能只对必要的缓存对象做提前更新,减少系统压力。而在23:00到第二日8:00之间,只对实时流媒体格式的缓存对象做提前更新校验,减轻系统压力,预留更多资源给其他任务使用。
在本公开的一些实施例中,对于缓存服务器的系统状态信息包括的地理位置信息,可以根据地理位置信息来确定缓存对象的更新条件。在一些示例性的实施例中,根据地理位置信息能够确定缓存服务器所处的位置是否位于边远地区,对于边远地区的缓存服务器,开启全量提前更新校验,可以在预设配置规则中设置边远地区的地理位置信息对应的提前时长,即边远地区的缓存服务器存储的所有缓存对象都提前其地理位置信息对应的提前时长进行更新。如此能够减少边远地区网络环境较差导致缓存对象更新延迟问题,能够避免缓存对象过期后第一个请求的服务质量差的问题。
在本公开的一些实施例中,对于缓存服务器的系统状态信息包括的网络环境状态,也可以根据网络环境状态来确定缓存对象的更新条件。具体可以在探测到与上游节点的网络质量比较好的时候,减少提前更新,降低系统负载。在网络质量较差时,为了优化用户体验,开 启更大范围的提前更新以及提高提前更新时长,以及增加更新校验的频次。
通过上述任一方式确定出客户端所请求的缓存对象的更新条件后,判断当前该缓存对象是否满足该更新条件。即判断当前系统时间是否达到该更新条件中包括的更新时刻。如果是,则确定需要提前更新该缓存对象,然后执行步骤104的操作。如果否,则确定不需要提前更新该缓存对象,则直接将当前存储的缓存对象发送给客户端。
步骤104:提前更新该缓存对象,以及对该对象获取请求进行响应。
若步骤103中确定出当前满足该缓存对象的更新条件,则从源服务器获取该缓存对象对应的最新版本对象,将本地存储的该缓存对象替换为最新版本对象;发送该最新版本对象给该客户端。即如图3中a图所示,缓存服务器发送对象更新请求给源服务器,该对象更新请求包括该缓存对象的对象标识信息。接收源服务器返回的该对象标识信息对应的最新版本对象,将本地存储的该缓存对象替换为该最新版本对象,并发送该最新版本对象给客户端。如此能够确保客户端获得最新版本对象,提高对象获取的准确性。
在本公开的另一些实施例中,可以发送本地的该缓存对象给客户端。同时通过本地后台从源服务器获取该缓存对象对应的最新版本对象,将本地存储的该缓存对象替换为最新版本对象。即如图3中b图所示,缓存服务器发送该缓存对象给客户端,同时在后台发送对象更新请求给源服务器,该对象更新请求包括该缓存对象的对象标识信息。接收源服务器返回的该对象标识信息对应的最新版本对象,将本地存储的该缓存对象替换为该最新版本对象。如此能够尽快对客户端进行响应,缩短用户的等待时间。
在本公开实施例中,源服务器在响应缓存服务器的对象更新请求时,若存在最新版本对象,则可以发送该最新版本对象及第一状态码给缓存服务器,第一状态码用于表示源服务器返回的是完整的最新版本对象。例如,第一状态码可以为HTTP状态码200。源服务器还可以比对最新版本对象和上述缓存对象,获得最新版本对象中与上述缓存对象不同的部分对象内容,将获得的部分对象内容及第二状态码发送给缓存服务器,第二状态码用于表示源服务器返回的是更新的部分对象内容,例如第二状态码可以为HTTP状态码206。缓存服务器接收到该部分对象内容后,根据该部分对象内容和该缓存对象生成最新版本对象。若源服务器中不存在最新版本对象,则源服务器可以发送第三状态码给缓存服务器,第三状态码用于表示源服务器中该对象尚未更新。例如,第三状态码可以为HTTP状态码304。
在本公开的一些实施例中,缓存服务器提前请求更新缓存对象时,可能源服务器中该缓存对象尚未更新,在这种情况下若也从源服务器获取对象并更新,则会造成网络资源的浪费,且增加源服务器的处理压力。为了节省网络资源,减少源服务器的压力,本公开实施例在从 源服务器获取该缓存对象的最新版本对象的过程中,还可以生成缓存对象对应的对象更新请求,在该对象更新请求中添加缓存对象的版本标识。然后发送该对象更新请求给源服务器。源服务器接收到该对象更新请求后,比较该版本标识与源服务器中存储的该缓存对象对应的最新版本对象的版本标识是否一致,如果是,则表明源服务器中尚未更新该对象,则发送对象未变更的指示消息给缓存服务器。缓存服务器接收到该指示消息后将本地存储的该缓存对象发送给客户端。如果源服务器比较出两个版本标识不一致,则表明源服务器中已更新了该对象,则将对应的最新版本对象发送给缓存服务器。缓存服务器接收源服务器返回的该版本标识对应的最新版本对象,将该最新版本对象发送给客户端,以及将本地存储的该缓存对象替换为该最新版本对象。
上述在对象更新请求中添加缓存对象的版本标识,具体可以在对象更新请求的报文头中添加版本标识。例如,假设对象更新请求为HTTP报文,则可以在HTTP报文头中的If-Modified-Since字段或ETag字段中添加版本标识,或者也可以采取其他能够被源服务器识别的对象版本信息等方式。在缓存对象没有已知可用的版本标识时,还可以在对象更新请求中添加缓存对象的最后更新时间,以使源服务器通过该最后更新时间来确定缓存对象的版本。
为了便于理解本公开提供的对象更新方法,下面结合附图进行说明。如图4所示,S1:接收客户端发送的对象获取请求。S2:判断是否存储有该对象获取请求对应的缓存对象,如果是,则执行步骤S3,如果否,则执行步骤S7。S3:判断该缓存对象的有效期是否到达,如果否,则执行步骤S4,如果是,则执行步骤S7。S4:获取该缓存对象对应的相关状态信息。S5:根据该相关状态信息,确定该缓存对象对应的更新条件。S6:判断该缓存对象是否满足该更新条件,如果是,则执行步骤S7,如果否,则执行步骤S8。S7:从源服务器获取该缓存对象对应的最新版本对象,发送该最新版本对象给客户端。S8:发送该缓存对象给客户端。
其中,步骤S7中可采用上述图3中a和b所示的任意一种方式,且发送给源服务器的对象获取请求中可携带该缓存对象的版本标识。
在本公开实施例中,在缓存服务器中缓存对象的有效期结束之前,依据缓存对象对应的相关状态信息来判断是否需要提前更新缓存对象,当需要提前更新时能够及时更新缓存对象,避免在有效期结束之后再更新对象造成对客户端的响应时延太长。本公开依据缓存对象的相关状态信息,提供了更智能的判断是否更新对象的方式,能够适应越来越复杂的网络服务环境,综合缓存服务器自身的系统状态、请求对象的客户端的状态以及对象本身的状态中的一种或多种的组合,通过综合这些方面来确定所采取的对象更新的策略。有利于提高缓存服务 器在不同地理位置、负载水平、网络环境、源服务器状态等条件下,为客户端提供更精确的缓存对象,缓存对象的更新更加及时。
本公开实施例还提供一种缓存对象更新装置,该装置用于执行上述任一实施例提供的缓存对象更新方法。参见图5,该装置包括:
接收模块501,设置为接收客户端发送的对象获取请求,确定对象获取请求对应的缓存对象存在且有效期未到达;
获取模块502,设置为获取缓存对象对应的相关状态信息;
判断模块503,设置为根据相关状态信息,判断是否提前更新缓存对象;
更新模块504,设置为如果判断模块判断出需要提前更新缓存对象,则提前更新缓存对象,以及对对象获取请求进行响应。
判断模块503,是设置为根据预设配置规则和相关状态信息,确定缓存对象对应的更新条件;判断当前缓存对象是否满足更新条件;如果是,则确定需要提前更新缓存对象;如果否,则确定不需要提前更新缓存对象。
在本公开实施例中,相关状态信息包括缓存对象对应的对象状态信息、客户端对应的客户端状态信息、缓存服务器对应的系统状态信息中的一种或多种的组合;判断模块503,是设置为根据相关状态信息,从预设配置规则中确定出缓存对象所符合的提前更新规则,提前更新规则包括提前更新缓存对象的提前时长;根据提前更新规则和缓存对象的有效期,生成缓存对象对应的更新条件。
更新条件包括:位于缓存对象的有效期之前提前时长的范围内接收到缓存对象对应的对象获取请求的时刻,和/或,根据缓存对象的有效期及提前更新规则中包括的提前时长所确定的提前更新时刻。
判断模块503,是设置为根据相关状态信息包括的缓存对象的对象类型,从预设配置规则中确定出对象类型对应的提前时长。
判断模块503,是设置为若提前时长大于预设阈值,则从预设配置规则中获取周期性更新规则,周期性更新规则用于规定每隔预设单位时长更新一次;将提前时长及周期性更新规则确定为缓存对象所符合的提前更新规则。
判断模块503,是设置为根据相关状态信息包括的缓存对象的对象标识信息,确定缓存对象在距离当前时间最近的预设时长内的被请求次数;若被请求次数大于预设次数,则从预设配置规则中获取预设次数对应的提前时长及到期更新规则,到期更新规则用于规定在对象的有效期结束时更新;将提前时长及到期更新规则确定为缓存对象所符合的提前更新规则。
更新模块504,是设置为从源服务器获取缓存对象对应的最新版本对象,将本地存储的缓存对象替换为最新版本对象;发送最新版本对象给客户端;或者,发送缓存对象给客户端;同时通过本地后台从源服务器获取缓存对象对应的最新版本对象,将本地存储的缓存对象替换为最新版本对象。
更新模块504,是设置为生成缓存对象对应的对象更新请求;在对象更新请求中添加缓存对象的版本标识;发送对象更新请求给源服务器;接收源服务器返回的状态码和或版本标识对应的最新版本对象。
更新模块504,还设置为在缓存对象的有效期结束时再次更新缓存对象。
更新模块504,还设置为若源服务器中不存在缓存对象对应的最新版本对象,则接收源服务器发送的第三状态码,第三状态码用于表示源服务器中缓存对象尚未更新。
本公开的上述实施例提供的缓存对象更新装置与本公开实施例提供的缓存对象更新方法出于相同的发明构思,具有与其存储的应用程序所采用、运行或实现的方法相同的有益效果。
本公开实施方式还提供一种电子设备,以执行上述缓存对象更新方法。请参考图6,其示出了本公开的一些实施方式所提供的一种电子设备的示意图。如图6所示,电子设备6包括:处理器600,存储器601,总线602和通信接口603,所述处理器600、通信接口603和存储器601通过总线602连接;所述存储器601中存储有可在所述处理器600上运行的计算机程序,所述处理器600运行所述计算机程序时执行本公开前述任一实施方式所提供的缓存对象更新方法。
其中,存储器601可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口603(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网、广域网、本地网、城域网等。
总线602可以是ISA总线、PCI总线或EISA总线等。所述总线可以分为地址总线、数据总线、控制总线等。其中,存储器601用于存储程序,所述处理器600在接收到执行指令后,执行所述程序,前述本公开实施例任一实施方式揭示的所述缓存对象更新方法可以应用于处理器600中,或者由处理器600实现。
处理器600可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器600中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器600可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(DSP)、专用集成 电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本公开实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本公开实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器601,处理器600读取存储器601中的信息,结合其硬件完成上述方法的步骤。
本公开实施例提供的电子设备与本公开实施例提供的缓存对象更新方法出于相同的发明构思,具有与其采用、运行或实现的方法相同的有益效果。
本公开实施方式还提供一种与前述实施方式所提供的缓存对象更新方法对应的计算机可读存储介质,请参考图7,其示出的计算机可读存储介质为光盘30,其上存储有计算机程序(即程序产品),所述计算机程序在被处理器运行时,会执行前述任意实施方式所提供的缓存对象更新方法。
需要说明的是,所述计算机可读存储介质的例子还可以包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他光学、磁性存储介质,在此不再一一赘述。
本公开的上述实施例提供的计算机可读存储介质与本公开实施例提供的缓存对象更新方法出于相同的发明构思,具有与其存储的应用程序所采用、运行或实现的方法相同的有益效果。
需要说明的是:
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本公开的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本公开的示例性实施例的描述中,本公开的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下示意图:即所要求保护的本公开要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本 公开的单独实施例。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本公开的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
以上所述,仅为本公开的具体实施方式,但本公开的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应以所述权利要求的保护范围为准。
工业实用性
在本公开中,在缓存服务器中缓存对象的有效期结束之前,依据缓存对象对应的相关状态信息来判断是否需要提前更新缓存对象,当需要提前更新时能够及时更新缓存对象,避免在有效期结束之后再更新对象造成对客户端的响应时延太长,为客户端提供更精确的缓存对象,缓存对象的更新更加及时。依据缓存对象的相关状态信息,提供了更智能的判断是否更新对象的方式,能够适应越来越复杂的网络服务环境。

Claims (14)

  1. 一种缓存对象更新方法,应用于缓存服务器,包括:
    接收客户端发送的对象获取请求,确定所述对象获取请求对应的缓存对象存在且有效期未到达;
    获取所述缓存对象对应的相关状态信息;
    根据所述相关状态信息,判断是否提前更新所述缓存对象;
    如果是,则提前更新所述缓存对象,以及对所述对象获取请求进行响应。
  2. 根据权利要求1所述的方法,其中,所述根据所述相关状态信息,判断是否提前更新所述缓存对象,包括:
    根据预设配置规则和所述相关状态信息,确定所述缓存对象对应的更新条件;
    判断当前所述缓存对象是否满足所述更新条件;
    如果是,则确定需要提前更新所述缓存对象;
    如果否,则确定不需要提前更新所述缓存对象。
  3. 根据权利要求1所述的方法,其中,所述相关状态信息包括所述缓存对象对应的对象状态信息、所述客户端对应的客户端状态信息、缓存服务器对应的系统状态信息中的一种或多种的组合;
    所述根据预设配置规则和所述相关状态信息,确定所述缓存对象对应的更新条件,包括:
    根据所述相关状态信息,从预设配置规则中确定出所述缓存对象所符合的提前更新规则,所述提前更新规则包括提前更新所述缓存对象的提前时长;
    根据所述提前更新规则和所述缓存对象的有效期,生成所述缓存对象对应的更新条件。
  4. 根据权利要求3所述的方法,其中,所述更新条件包括:位于所述缓存对象的有效期之前提前时长的范围内接收到所述缓存对象对应的对象获取请求的时刻,和/或,根据所述缓存对象的有效期及所述提前更新规则中包括的提前时长所确定的提前更新时刻。
  5. 根据权利要求3或4所述的方法,其中,所述根据所述相关状态信息,从预设配置规则中确定出所述缓存对象所符合的提前更新规则,包括:
    根据所述相关状态信息包括的所述缓存对象的对象类型,从预设配置规则中确定出所述对象类型对应的提前时长。
  6. 根据权利要求3或4所述的方法,还包括:
    若所述提前时长大于预设阈值,则从所述预设配置规则中获取周期性更新规则,所述周 期性更新规则用于规定每隔预设单位时长更新一次;
    将所述提前时长及所述周期性更新规则确定为所述缓存对象所符合的提前更新规则。
  7. 根据权利要求3或4所述的方法,其中,所述根据所述相关状态信息,从预设配置规则中确定出所述缓存对象所符合的提前更新规则,包括:
    根据所述相关状态信息包括的所述缓存对象的对象标识信息,确定所述缓存对象在距离当前时间最近的预设时长内的被请求次数;
    若所述被请求次数大于预设次数,则从预设配置规则中获取所述预设次数对应的提前时长及到期更新规则,所述到期更新规则用于规定在对象的有效期结束时更新;
    将所述提前时长及所述到期更新规则确定为所述缓存对象所符合的提前更新规则。
  8. 根据权利要求1所述的方法,其中,所述更新所述缓存对象,以及对所述对象获取请求进行响应,包括:
    从源服务器获取所述缓存对象对应的最新版本对象,将本地存储的所述缓存对象替换为所述最新版本对象;发送所述最新版本对象给所述客户端;或者,
    发送所述缓存对象给所述客户端;同时通过本地后台从源服务器获取所述缓存对象对应的最新版本对象,将本地存储的所述缓存对象替换为所述最新版本对象。
  9. 根据权利要求8所述的方法,其中,所述从源服务器获取所述缓存对象对应的最新版本对象,包括:
    生成所述缓存对象对应的对象更新请求;
    在所述对象更新请求中添加所述缓存对象的版本标识;
    发送所述对象更新请求给源服务器;
    接收所述源服务器返回的所述版本标识对应的最新版本对象。
  10. 根据权利要求1-8任一项所述的方法,还包括:
    在所述缓存对象的有效期结束时再次更新所述缓存对象。
  11. 根据权利要求1-9任一项所述的方法,其中,所述更新所述缓存对象包括:
    若源服务器中不存在所述缓存对象对应的最新版本对象,则接收所述源服务器发送的第三状态码,所述第三状态码用于表示所述源服务器中所述缓存对象尚未更新。
  12. 一种缓存对象更新装置,包括:
    接收模块,设置为接收客户端发送的对象获取请求,确定所述对象获取请求对应的缓存对象存在且有效期未到达;
    获取模块,设置为获取所述缓存对象对应的相关状态信息;
    判断模块,设置为根据所述相关状态信息,判断是否提前更新所述缓存对象;
    更新模块,设置为如果所述判断模块判断出需提前更新所述缓存对象,则提前更新所述缓存对象,以及对所述对象获取请求进行响应。
  13. 一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述处理器运行所述计算机程序以实现如权利要求1-11任一项所述的方法。
  14. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述程序被处理器执行实现如权利要求1-11中任一项所述的方法。
PCT/CN2022/082248 2021-03-30 2022-03-22 一种缓存对象更新方法、装置、设备及存储介质 WO2022206487A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110340680.1A CN113515530B (zh) 2021-03-30 2021-03-30 一种缓存对象更新方法、装置、设备及存储介质
CN202110340680.1 2021-03-30

Publications (1)

Publication Number Publication Date
WO2022206487A1 true WO2022206487A1 (zh) 2022-10-06

Family

ID=78062100

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/082248 WO2022206487A1 (zh) 2021-03-30 2022-03-22 一种缓存对象更新方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN113515530B (zh)
WO (1) WO2022206487A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115378920A (zh) * 2022-10-26 2022-11-22 南京大鱼半导体有限公司 一种调节音频时延的方法及设备
CN116701800A (zh) * 2023-08-07 2023-09-05 广州市千钧网络科技有限公司 页面内容处理方法、装置、计算机设备及介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113515530B (zh) * 2021-03-30 2023-06-13 贵州白山云科技股份有限公司 一种缓存对象更新方法、装置、设备及存储介质
CN114531489A (zh) * 2022-01-14 2022-05-24 北京字节跳动网络技术有限公司 一种请求响应方法及装置
CN115080625B (zh) * 2022-07-21 2022-11-04 成都薯片科技有限公司 基于Spring Cache缓存框架的缓存方法、装置、设备及存储介质
CN115550424B (zh) * 2022-12-02 2023-03-14 苏州万店掌网络科技有限公司 一种数据缓存方法、装置、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401950A (zh) * 2013-08-21 2013-11-20 网宿科技股份有限公司 缓存异步刷新方法、缓存服务器处理请求方法和系统
CN106599721A (zh) * 2016-12-13 2017-04-26 微梦创科网络科技(中国)有限公司 一种基于缓存的数据访问方法及装置
CN107291756A (zh) * 2016-04-01 2017-10-24 阿里巴巴集团控股有限公司 数据缓存的方法及装置
CN110069267A (zh) * 2019-03-15 2019-07-30 平安普惠企业管理有限公司 数据更新方法、装置、计算机设备及存储介质
CN111131856A (zh) * 2019-12-31 2020-05-08 北京奇艺世纪科技有限公司 一种缓存过期时间调整方法、装置、电子设备及存储介质
CN113515530A (zh) * 2021-03-30 2021-10-19 贵州白山云科技股份有限公司 一种缓存对象更新方法、装置、设备及存储介质

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6760813B1 (en) * 2001-12-20 2004-07-06 Cisco Technology, Inc. Devices, softwares and methods for preemptively updating expiring entries in a cache memory to anticipate future inquiries
CN102984286B (zh) * 2012-11-14 2015-03-04 上海牙木通讯技术有限公司 一种dns服务器的缓存更新方法、装置及系统
CN106815287A (zh) * 2016-12-06 2017-06-09 中国银联股份有限公司 一种缓存管理方法及装置
CN107066570A (zh) * 2017-04-07 2017-08-18 聚好看科技股份有限公司 数据管理方法及装置
CN108848173A (zh) * 2018-06-25 2018-11-20 郑州云海信息技术有限公司 一种数据更新方法、装置、设备及可读存储介质
CN109828749A (zh) * 2018-12-29 2019-05-31 北京航天云路有限公司 兼顾快速响应和数据更新的数据缓存方法及系统
CN112445986B (zh) * 2019-08-30 2024-05-24 贵州白山云科技股份有限公司 一种缓存信息的更新方法、推送方法、装置及介质
CN110766464A (zh) * 2019-10-23 2020-02-07 上海连尚网络科技有限公司 一种用于控制呈现信息的方法与设备
CN110913239B (zh) * 2019-11-12 2021-03-02 西安交通大学 一种精细化的移动边缘计算的视频缓存更新方法
CN111125128B (zh) * 2019-12-10 2023-07-25 苏宁云计算有限公司 一种缓存更新方法、装置及系统
CN111259034A (zh) * 2020-02-17 2020-06-09 腾讯科技(深圳)有限公司 一种缓存数据管理方法和相关装置
CN111563216B (zh) * 2020-07-16 2020-11-06 平安国际智慧城市科技股份有限公司 本地数据缓存方法、装置及相关设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401950A (zh) * 2013-08-21 2013-11-20 网宿科技股份有限公司 缓存异步刷新方法、缓存服务器处理请求方法和系统
CN107291756A (zh) * 2016-04-01 2017-10-24 阿里巴巴集团控股有限公司 数据缓存的方法及装置
CN106599721A (zh) * 2016-12-13 2017-04-26 微梦创科网络科技(中国)有限公司 一种基于缓存的数据访问方法及装置
CN110069267A (zh) * 2019-03-15 2019-07-30 平安普惠企业管理有限公司 数据更新方法、装置、计算机设备及存储介质
CN111131856A (zh) * 2019-12-31 2020-05-08 北京奇艺世纪科技有限公司 一种缓存过期时间调整方法、装置、电子设备及存储介质
CN113515530A (zh) * 2021-03-30 2021-10-19 贵州白山云科技股份有限公司 一种缓存对象更新方法、装置、设备及存储介质

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115378920A (zh) * 2022-10-26 2022-11-22 南京大鱼半导体有限公司 一种调节音频时延的方法及设备
CN115378920B (zh) * 2022-10-26 2023-04-14 南京大鱼半导体有限公司 一种调节音频时延的方法及设备
CN116701800A (zh) * 2023-08-07 2023-09-05 广州市千钧网络科技有限公司 页面内容处理方法、装置、计算机设备及介质

Also Published As

Publication number Publication date
CN113515530A (zh) 2021-10-19
CN113515530B (zh) 2023-06-13

Similar Documents

Publication Publication Date Title
WO2022206487A1 (zh) 一种缓存对象更新方法、装置、设备及存储介质
US11461402B2 (en) Routing based request correlation
CN106534243B (zh) 基于http协议的缓存、请求、响应方法及相应装置
WO2019165665A1 (zh) 一种域名解析方法、服务器及系统
CN110830564B (zh) Cdn调度方法、装置、系统及计算机可读存储介质
WO2017133496A1 (zh) 一种资源获取的方法及相关设备
CN111782692B (zh) 一种频率控制方法及装置
EP3244590B1 (en) Network node, endpoint node and method of receiving an interest message
US11032394B1 (en) Caching techniques
TW201724001A (zh) 全域資訊獲取、處理及更新方法、裝置和系統
WO2017114397A1 (zh) 一种实现心跳机制的方法、装置及系统
TW201724825A (zh) 全域資訊獲取、處理及更新、方法、裝置和系統
US20210344589A1 (en) Method, server, and system for data stream redirecting
CN111970195A (zh) 数据传输方法和流式数据传输系统
CN108337280B (zh) 一种资源更新方法及装置
WO2020098455A1 (zh) 媒体流的实时递送方法及服务器
CN112579639A (zh) 数据处理方法、装置、电子设备及存储介质
CN115473858A (zh) 数据传输方法和流式数据传输系统
WO2018090315A1 (zh) 数据请求的处理方法及缓存系统
CN113133027B (zh) 一种通信方法、服务器、终端及通信系统
WO2016082492A1 (zh) 一种原始资源通告的方法及相应的节点
CN112235271A (zh) 内容分发网络cdn设备及其自适应安全回源方法
CN115134618B (zh) 直播流生命周期信息处理方法、装置及计算设备
JP5068278B2 (ja) キャッシュ保持期間よりもブラウザ保持期間を長く設定するデータ配信装置及びキャッシュサーバ及び方法
CN105431835A (zh) 内容传递网络中的自适应流式传输段文件的碎片整理

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22778670

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22778670

Country of ref document: EP

Kind code of ref document: A1