Cache data refreshing method and device, equipment and storage medium

By dividing candidate cache partitions in node servers in distributed systems and determining the target cache partitions based on target prefix fields for accurate refresh, the problem of validity period waste caused by cache data refresh methods in the existing technology is solved, and system performance is improved.

CN119917537APending Publication Date: 2025-05-02BEIJING JINGDONG QIANSHITECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311435297.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The refresh method of cached data in a distributed system requires synchronous operation of the entire cache area, resulting in the validity period of some cached data being wasted, affecting system performance.

Method used

By pre-dividing candidate cache partitions in the cache area of ​​the node server, determining the target cache partition according to the target prefix field, and performing accurate refresh operations to reduce invalid refreshes.

Benefits of technology

It realizes accurate refresh of cached data in a distributed system, reduces the waste of cached data validity period and improves the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917537A_ABST
    Figure CN119917537A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a cache data refreshing method and device, equipment and a storage medium, and relates to the technical field of computers, the method can be applied to a current node server in a distributed system, and the method can comprise the steps that under the condition that a cache refreshing request is received, based on a target prefix field carried by the cache refreshing request, the current node server is refreshed according to the target prefix field; determining a target cache partition from each candidate cache partition of the current node server; wherein the target prefix field is used for uniquely representing one service type; and performing a refreshing operation on the current service data cached in the target cache partition. By adopting the technical scheme of the embodiment of the invention, when certain service data is invalid, the target cache partition corresponding to the service type can be accurately refreshed according to the service type to which the service data belongs, so that the waste of the validity period of the cache data can be reduced, and the overall performance of a system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a method, device, equipment and storage medium for refreshing cache data. Background Art

[0002] At present, distributed systems have been widely used in logistics, finance, e-commerce and other fields. Among them, the distributed system may include multiple node servers, each of which has a corresponding cache area for storing the business data of the corresponding node server. In the prior art, since each node server maintains the same system (i.e., distributed system), when a certain business data in the system fails, it is necessary to synchronously refresh the entire cache area of ​​each node server to ensure the data consistency of each node server.

[0003] However, in the process of implementing the present invention, it was found that there are at least the following problems in the prior art: the prior art refresh method for cached data (i.e., business data cached in the cache area of ​​the node server) requires refreshing the entire cache area, which will cause the validity period of some cached data in the cache area (i.e., other business data in the cache area except the invalid business data) to be wasted, affecting the overall performance of the system. Summary of the invention

[0004] The embodiments of the present invention provide a method, device, equipment and storage medium for refreshing cache data, which can reduce the waste of the validity period of cache data, thereby improving the overall performance of the system.

[0005] In a first aspect, an embodiment of the present invention provides a method for refreshing cache data, which can be applied to a current node server in a distributed system. The method may include: upon receiving a cache refresh request, determining a target cache partition from each candidate cache partition of the current node server based on a target prefix field carried in the cache refresh request; wherein the target prefix field is used to uniquely characterize a business type; and refreshing the current business data cached in the target cache partition.

[0006] In a second aspect, an embodiment of the present invention further provides a cache data refresh device, which can be configured in a current node server in a distributed system, and the device can include: a determination module and an execution module;

[0007] Specifically, the determination module is used to determine the target cache partition from the candidate cache partitions of the current node server based on the target prefix field carried in the cache refresh request when the cache refresh request is received; wherein the target prefix field is used to uniquely represent a service type;

[0008] The execution module is used to refresh the current business data cached in the target cache partition.

[0009] In a third aspect, an embodiment of the present invention provides a cache data refresh device, the cache data refresh device comprising:

[0010] one or more processors;

[0011] A memory for storing one or more programs;

[0012] When the one or more programs are executed by the one or more processors, the one or more processors implement the cache data refreshing method provided by any embodiment of the present invention.

[0013] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for refreshing cache data as provided in any embodiment of the present invention.

[0014] The embodiments of the above invention have the following advantages or beneficial effects:

[0015] In the technical solution provided by the embodiment of the present invention, for the current node server in each node server of the distributed system, the cache area of ​​the current node server can be pre-divided into candidate cache partitions corresponding to each business type maintained by the current node server according to each business type maintained by the current node server, and each candidate cache partition obtained by the division can be used to store business data of the corresponding business type. When a certain business data in the system fails, a cache refresh request carrying a target prefix field can be initiated to the current node server, and the target prefix field can be used to characterize the business type to which the failed business data belongs. Then, the target cache partition corresponding to the business type represented by the target prefix field can be determined from each candidate cache partition of the current node server based on the target prefix field. Then, the target cache partition is the cache partition that may store the failed business data, and the current business data cached in the target cache partition can be accurately refreshed. It can be seen that in the technical solution provided by the embodiment of the present invention, by pre-dividing the cache area of ​​the current node server into candidate cache partitions according to the business type, it is possible to achieve accurate caching of cache data according to the business type in the current node service. Based on this, when a certain business data in the system becomes invalid, the target cache partition corresponding to the business type can be accurately refreshed according to the business type to which the business data belongs. This can reduce the waste of the validity period of the cached data and improve the overall performance of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1It is a flow chart of a method for refreshing cache data provided by an embodiment of the present invention;

[0017] Figure 2 It is a flowchart of another method for refreshing cache data provided by an embodiment of the present invention;

[0018] Figure 3 It is a schematic diagram of the structure of a prefix tree provided by an embodiment of the present invention;

[0019] Figure 4 It is a flowchart of another method for refreshing cache data provided by an embodiment of the present invention;

[0020] Figure 5 It is a flowchart of another method for refreshing cache data provided by an embodiment of the present invention;

[0021] Figure 6 It is a structural schematic diagram of a cache data refresh device provided by an embodiment of the present invention;

[0022] Figure 7 It is a structural schematic diagram of a cache data refresh device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0024] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0025] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0026] It should be noted that, in the embodiments of the present invention, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0027] In the description of the embodiments of the present invention, unless otherwise specified, “plurality” or “each” means two or more than two.

[0028] Before describing in detail the method for refreshing cache data provided by the embodiment of the present invention, the technical background of the embodiment of the present invention is described in detail below.

[0029] For a distributed system in a certain business scenario (for example, a logistics scenario), the distributed system may include node servers and configuration servers, wherein the configuration server may be used to perform diversion operations on business requests initiated by the client. In a possible implementation, after the configuration server receives the business request initiated by the client, it may forward the received business request to a node server in the distributed system based on diversion principles such as load balancing, and the node server processes the business request. In the process of processing the business request, the node server needs to obtain the business data corresponding to the business request from the database storing the full amount of business data (for example, the business data may be the business logic rules that need to be referenced when processing the business request, etc.), and then the business request may be processed based on the business data. In actual applications, since the client may repeatedly initiate the same business request continuously, in the prior art, a cache area may be created in each node server respectively. When processing a business request, the node server can cache the business data corresponding to the business request in the cache area after obtaining the business data from the database storing the full business data. In this way, the next time the node server obtains the same business request, it can process the business request based on the locally cached business data without having to obtain the business data from the database storing the full business data.

[0030] During the operation of the distributed system, when a certain business data fails, in order to ensure the normal operation of the system, the business personnel need to refresh the business data. Exemplarily, the business personnel can trigger the server to initiate a refresh request for the business data to the distributed system through the configuration operation performed on the server. In a possible implementation, after the configuration server receives the refresh request, it can forward the refresh request to a node server, and the node server processes the refresh request for the business data. Specifically, the node server can refresh the business data in the database storing the full amount of business data (for example, delete the business data stored in the database). Since a node server may cache the business data in a local cache area during the processing of a business request, and the same business request may be diverted to different node servers, it may appear that the business data is currently cached in the cache areas of multiple node servers. In order to ensure the data consistency of each node server and to ensure the consistency of the cache area of ​​each node server with the database storing the full amount of business data, in the prior art, the business data cached in the entire cache area of ​​each node server can be refreshed synchronously. However, this will cause the validity period of some cached data in the cache area to be wasted, affecting the overall performance of the system.

[0031] In view of the above problems existing in the prior art, the embodiments of the present invention improve the refreshing method of cache data in the prior art.

[0032] Figure 1 A flowchart of a cache data refresh method provided in an embodiment of the present invention, which can be applied to an application scenario where cache data of each node server in a distributed system is refreshed. The method can be executed by a cache data refresh device provided in an embodiment of the present invention, which can be implemented in software and / or hardware and integrated in a cache data refresh device.

[0033] The cache data refresh method provided in the embodiment of the present invention can be applied to a distributed system, wherein the distributed system includes various node servers. In the technical solution provided in the embodiment of the present invention, the refresh mode of cache data of each node server (i.e., the processing process for cache refresh request) is exactly the same, so in the embodiment of the present invention, the cache data refresh method will be applied to any node server among the node servers (i.e., the current node server in the embodiment of the present invention) as an example for explanation.

[0034] like Figure 1 As shown, the method for refreshing cache data provided by the embodiment of the present invention specifically includes the following steps:

[0035] S110 . When a cache refresh request is received, a target cache partition is determined from candidate cache partitions of the current node server based on a target prefix field carried in the cache refresh request.

[0036] In a possible implementation, a cache refresh request may be a request initiated by the server to the current node server through the configuration server to refresh the cache data of the current node server after a certain business data becomes invalid. For example, a business person may trigger the server to initiate a cache refresh request to the configuration server by performing a business change operation or a business deletion operation in the server. After receiving the cache refresh request, the configuration server may forward the received cache refresh request to the current node server based on the load balancing and other diversion principles.

[0037] The cache refresh request carries a target prefix field, which is used to uniquely represent a service type. Specifically, the target prefix field is used to represent the service type to which the invalid service data belongs.

[0038] For the current node server, in an embodiment of the present invention, the cache area of ​​the current node server can be pre-divided into candidate cache partitions corresponding to the various business types maintained by the current node server according to the various business types maintained by the current node server, and each candidate cache partition obtained by the division can be used to store business data of the corresponding business type. After receiving the cache refresh request carrying the target prefix field forwarded by the configuration server, the current node server can determine the target cache partition corresponding to the business type represented by the target prefix field from the candidate cache partitions of the current node server based on the business type represented by the target prefix field, and the target cache partition is also the cache partition that may store invalid business data.

[0039] For example, taking the cache data refresh method applied to the logistics quotation scenario as an example, the distributed system can be a logistics quotation system for pricing logistics orders initiated by users. Correspondingly, the business types can be divided according to the information such as the origin and destination of the order. For example, the business types can include: business types between city A and city B, business types between city B and city C, and business types between city A and city C.

[0040] In a possible implementation, the business types maintained by the current node server may be all business types in the current business scenario, that is, the business types maintained by each node server are exactly the same, and correspondingly, the candidate cache partitions of each node server are the same.

[0041] In another possible implementation, the business types maintained by the current node server may be some business types in the current business scenario, and there are overlaps between the business types maintained by the node servers. Correspondingly, there may or may not be overlaps between the candidate cache partitions of any two node servers. For example, node server A is used to maintain business type A and business type B, node server B is used to maintain business type A, and node server C is used to maintain business type C.

[0042] S120: Refresh the current business data cached in the target cache partition.

[0043] After the current node server determines the target cache partition that may contain invalid business data, in order to ensure data consistency among the node servers in the system, the current business data cached in the target cache partition may be refreshed. Exemplarily, the refresh operation may be to delete the current business data cached in the target cache partition.

[0044] Taking the cache data refresh method applied to the logistics quotation scenario as an example, the business data in the embodiment of the present invention may be a quotation rule for a certain business type (for example, a quotation rule for the business between city A and city B). When the current node server processes a business request under this business type, it may price the logistics order in the business request based on the quotation rule.

[0045] In a possible implementation, an embodiment of the present invention can deploy a cache component in the current node server by means of aspect-oriented programming (AOP). After receiving a cache refresh request, the current node server can first refresh the invalid business data in the database storing the full business data. After receiving the operation success information returned by the database storing the full business data, the cache component deployed in the current node server can intercept the operation success information, and perform the following operations after interception: Based on the target prefix field carried by the cache refresh request, determine the target cache partition from the candidate cache partitions of the current node server, and refresh the current business data cached in the target cache partition. In this way, the improvement of the cache refresh method can be completed on the basis of the existing distributed system without reconfiguring the distributed system.

[0046] Optionally, a refresh operation is performed on the current business data cached in the target cache partition, including: when the cache refresh request carries the target business data corresponding to the target prefix field, updating the current business data cached in the target cache partition to the target business data.

[0047] In actual applications, business personnel can not only trigger the server to initiate a cache refresh request to the current node server through the configuration server through a business deletion operation, but also trigger the server to initiate a cache refresh request to the current node server through the configuration server through a business change operation. Among them, the business deletion operation can be a deletion operation for a certain sub-business, and the business change operation can be a modification operation for a certain sub-business. In this case, business personnel need to upload the changed business data (i.e., the target business data in the embodiment of the present invention) when performing a business change operation, and the cache refresh request will carry the changed business data. Based on this, in an embodiment of the present invention, when the cache refresh request carries the target business data corresponding to the target prefix field, the current business data cached in the target cache partition can be deleted, and the target business data can be updated to the target cache partition. In this way, the data in the cache area of ​​the current node server can be guaranteed to be up-to-date.

[0048] Optionally, after refreshing the current business data cached in the target cache partition, the cache data refresh method provided by an embodiment of the present invention also includes: initiating a second broadcast request carrying the target prefix field to the message server when the cache refresh request does not carry the target business data corresponding to the target prefix field, for instructing the message server to send a third broadcast message to other node servers in the distributed system, so that the other node servers perform a cache refresh operation for the target prefix field.

[0049] In order to ensure data consistency of each node server, in an embodiment of the present invention, the refresh operation performed by the current node server may be broadcasted through a message server, so that other node servers can perform refresh synchronization with the current node server in a timely manner.

[0050] Exemplarily, after receiving the second broadcast request, the message server can determine other node servers that are currently subscribed to the second broadcast request (that is, all node servers in the distributed system except the current node server), and send a third broadcast message to the other node servers. After receiving the third broadcast message, the other node servers can search for the target cache partition corresponding to the target prefix field in the candidate cache partitions of the other node servers based on the target prefix field carried by the third broadcast message. If the search is successful, the business data in the target cache partition can be refreshed; otherwise, if the search fails, the third broadcast message can be ignored.

[0051] In a possible implementation, the message server may be a Kafka (an open source stream processing platform) server. Of course, in practical applications, the message server may also be other servers for broadcasting subscription information.

[0052] In the method for refreshing cache data provided by the embodiment of the present invention, for the current node server in each node server of the distributed system, the cache area of ​​the current node server can be pre-divided into candidate cache partitions corresponding to each business type maintained by the current node server according to each business type maintained by the current node server, and each candidate cache partition obtained by the division can be used to store cache data of the corresponding business type. When a certain business data in the system fails, a cache refresh request carrying a target prefix field can be initiated to the current node server, and the target prefix field can be used to characterize the business type to which the failed business data belongs. Then, the target cache partition corresponding to the business type represented by the target prefix field can be determined from each candidate cache partition of the current node server based on the target prefix field. Then, the target cache partition is the cache partition that may store the failed business data, and the current business data cached in the target cache partition can be accurately refreshed. It can be seen that in the technical solution provided by the embodiment of the present invention, by pre-dividing the cache area of ​​the current node server into candidate cache partitions according to the business type, it is possible to achieve accurate caching of cache data according to the business type in the current node service. Based on this, when a certain business data in the system becomes invalid, the target cache partition corresponding to the business type can be accurately refreshed according to the business type to which the business data belongs. This can reduce the waste of the validity period of the cached data and improve the overall performance of the system.

[0053] Reference Figure 2 , is a flow chart of another method for refreshing cache data provided by an embodiment of the present invention. The method in this embodiment can be combined with various optional solutions in the method for refreshing cache data provided by the previous embodiment, and the method for refreshing cache data provided by the previous embodiment is further optimized. Figure 2 As shown, the specific steps include:

[0054] S210. When a cache refresh request is received, a target cache partition is determined from candidate cache partitions of the current node server based on the business level identifiers in the target prefix field carried in the cache refresh request and the arrangement order of the business level identifiers.

[0055] Among them, each service level identifier may be a plurality of service level identifiers arranged in sequence in the target prefix field according to a preset sorting rule. The preset sorting rule may be a predetermined sorting rule, for example, it may be sorted according to the size of the service level corresponding to the service level identifier (in the embodiment of the present invention, the lower the level, the front, and the higher the level, the back).

[0056] In a possible implementation, in an embodiment of the present invention, a first-level business division can be performed on the business types according to the business functions of each node server to obtain multiple business types under the first level, and corresponding business level identifiers can be determined for the multiple business types under the first level respectively; then, a second-level business division can be performed on the business types according to the business functions of each node server to obtain multiple business types under the second level, and corresponding business level identifiers can be determined for the multiple business types under the second level respectively; then, a third-level business division can be performed on the business types according to the business functions of each node server to obtain multiple business types under the third level, and corresponding business level identifiers can be determined for the multiple business types under the third level respectively.

[0057] Still taking the cache data refresh method applied to the logistics quotation scenario as an example, in the embodiment of the present invention, the business type can be first divided into the first level of business according to the logistics order type, and multiple business types under the first level are obtained, such as express delivery and express transportation. The business level identifier corresponding to the express delivery class can be A1, and the business level identifier corresponding to the express transportation class can be A2. Afterwards, the business type can be divided into the second level of business according to the time period corresponding to the logistics order, and multiple business types under the second level are obtained, such as flat time period class and peak time period class. The business level identifier corresponding to the flat time period class can be B1, and the business level identifier corresponding to the peak time period class can be B2; then, the business type can be divided into the third level of business according to the origin and destination corresponding to the logistics order, and multiple business types under the third level are obtained, such as the business class between city A and city B (hereinafter referred to as business class a), the business class between city B and city C (hereinafter referred to as business class b), the business class between city A and city C (hereinafter referred to as business class c), and so on. For example, the business level identifier corresponding to business class a may be C1, the business level identifier corresponding to business class b may be C2, and the business level identifier corresponding to business class c may be C3.

[0058] Exemplarily, if the target prefix field is A1; B1; C1, the current node server may determine the candidate cache partition storing the business data of business class a under the off-peak time period class under the express class as the target cache partition.

[0059] Optionally, based on each business level identifier and the arrangement order of each business level identifier, determining the target cache partition from each candidate cache partition of the current node server may include: based on each business level identifier and the arrangement order of each business level identifier, determining the query path of the prefix tree for the current node server; according to the query path, searching the prefix tree of the current node server for the target leaf node corresponding to the target prefix field, and determining the candidate cache partition corresponding to the target leaf node as the target cache partition.

[0060] Wherein, each non-root node in the prefix tree corresponds to a service level identifier, and each leaf node in the prefix tree corresponds to a different candidate cache partition.

[0061] In an embodiment of the present invention, after the business type is divided into multiple levels according to the business functions of each node server, a prefix tree of the current node server can be constructed based on the division results and the business types of each level maintained by the current node server. Each node level of the prefix tree (except the level corresponding to the root node) corresponds to the business level of the business type. After the prefix tree of the current node server is constructed, the corresponding candidate cache partitions can be determined for each leaf node in the prefix tree.

[0062] Reference Figure 3 , is a schematic diagram of a prefix tree structure provided by an embodiment of the present invention. Figure 3 As shown, a root node can be created first, and then sub-nodes corresponding to each business type of the first level can be created at the next level of the root node, such as Figure 3 Node A1 and node A2 in the example, wherein node A1 and node A2 correspond to business level identifier A1 and business level identifier A2, respectively. Similarly, child nodes corresponding to each business type of the second level can be created at the next level of node A1 and node A2, respectively, such as Figure 3 Then, sub-nodes corresponding to the service types of the third level can be created at the next level of nodes B1 and B2, for example: Figure 3 Node C1, node C2, and Figure 3 Other nodes not shown in the figure (such as C3, etc.). It should be noted that Figure 3 For the convenience of drawing, the child nodes of the B2 node are not shown. In actual applications, the child nodes of the B2 node are the same as the child nodes of the B1 node. Figure 3 As shown, after the prefix tree of the current node server is constructed, the corresponding candidate cache partitions can be determined for each leaf node (eg, node C1, node C2, etc.) in the prefix tree.

[0063] In addition, it should be noted that, for non-leaf nodes in the prefix tree, each non-leaf node stores a pointer to its child node (used to represent the path of the child node).

[0064] Exemplarily, if the target prefix field is A1; B1; C1, the query path determined for the prefix tree of the current node server can be: first search for node A1 corresponding to the business level identifier A1 according to the pointers of each child node stored in the root node, then search for node B1 corresponding to the business level identifier B1 according to the pointers of each child node stored in node A1, and then search for node C1 corresponding to the business level identifier C1 according to the pointers of each child node stored in node B1. The node C1 is the target leaf node, and the candidate cache partition corresponding to the target leaf node can be determined as the target cache partition.

[0065] It can be seen that in the embodiment of the present invention, in order to facilitate hierarchical search for the target cache partition corresponding to the target prefix field, a prefix tree can be constructed for each node server according to the division level of the business type, and each leaf node in the prefix tree can be associated with each candidate cache partition. In this way, when a certain business data in the system fails, the target cache partition corresponding to the target prefix field can be quickly found based on the business level identifiers in the target prefix field and combined with the prefix tree.

[0066] S220: Refresh the current business data cached in the target cache partition.

[0067] In an embodiment of the present invention, based on the aforementioned embodiment, when partitioning the cache area of ​​the current node server, multiple business levels for dividing the business types can be determined according to the business needs in the current business scenario, and then the business types can be divided layer by layer in the order of the business levels. Afterwards, the cache area of ​​the current node server can be partitioned in a more fine-grained manner according to the results of the division of each layer, and then each candidate cache partition with higher accuracy can be obtained. In this way, when a certain business data in the system fails, a more accurate refresh operation can be achieved based on the business level identifiers in the target prefix field.

[0068] It should be noted that the cache data refresh method proposed in the embodiment of the present invention and the aforementioned embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the aforementioned embodiment, and the beneficial effects of the aforementioned embodiment are also applicable to this embodiment.

[0069] Reference Figure 4, is a flow chart of another method for refreshing cache data provided by an embodiment of the present invention. The method in this embodiment can be combined with various optional solutions in the method for refreshing cache data provided by the previous embodiment, and the method for refreshing cache data provided by the previous embodiment is further optimized. Figure 4 As shown, the specific steps include:

[0070] S410: When a cache refresh request is received, a target cache partition is determined from candidate cache partitions of the current node server based on a target prefix field carried in the cache refresh request.

[0071] S420: Delete the current business data cached in the target cache partition.

[0072] S430: Update the target business data corresponding to the target prefix field carried in the cache refresh request into the target cache partition.

[0073] S440: Determine a first version identifier corresponding to the target prefix field from the version information table stored in the current node server, and adjust the first version identifier to a second version identifier based on a preset adjustment rule.

[0074] The version information table may be a table for storing the correspondence between prefix fields and version identifiers. Exemplarily, the version information table may be a two-dimensional information table including a prefix field column and a version identifier column. The version identifier may be used to characterize the version of the business data currently cached by the candidate cache partition corresponding to the corresponding prefix field. Exemplarily, the version identifier may be a unique number generated based on a predetermined numbering rule, or a timestamp may be used as the version identifier.

[0075] The preset adjustment rule may be a preset adjustment rule. Taking the version identifier as a serial number as an example, the preset adjustment rule may be to add one to the first version identifier.

[0076] S450. Initiate a cache synchronization request carrying a target prefix field, target business data, and a second version identifier to the database server, to instruct the database server to update the first business data corresponding to the target prefix field stored in the database server to the target business data, and to update the third version identifier corresponding to the target prefix field in the version information table stored in the database server to the second version identifier.

[0077] Exemplarily, the database server may be a Redis (an open source memory cache database) server.

[0078] Since the data that can be stored in the cache area of ​​the current node server is limited, in the embodiment of the present invention, part of the cached data can also be cached to the Redis server. When reading, writing or changing the Redis server, the key value can be the prefix field, and the value value can be the business data.

[0079] S460. Initiate a first broadcast request carrying a target prefix field to the message server, which is used to instruct the message server to send a first broadcast message to other node servers in the distributed system, so that the other node servers perform cache synchronization operations on the target prefix field based on the version information table stored by the other node servers and the version information table stored by the database server.

[0080] Exemplarily, the second node server is any node server among the other node servers. After receiving the first broadcast message, the second node server can determine the version identifier A corresponding to the target prefix field from the locally stored version information table, and then obtain the version information table stored in the database server, and determine the version identifier B corresponding to the target prefix field therefrom. If the level of version identifier A is lower than version identifier B, the cache synchronization operation for the target prefix field can be performed; otherwise, the cache synchronization operation for the target prefix field is not performed.

[0081] Optionally, the cache data refresh method provided by the embodiment of the present invention may also include: upon receiving a second broadcast message sent by a message server, based on the current prefix field carried by the second broadcast message, determining a fourth version identifier corresponding to the current prefix field from the version information table stored by the current node server; obtaining the version information table stored by the database server, and determining a fifth version identifier corresponding to the current prefix field from the version information table stored by the database server; and performing a cache synchronization operation on the current prefix field when it is determined that the fourth version identifier and the fifth version identifier meet preset conditions.

[0082] Among them, the preset condition can be a predetermined condition, for example, the preset condition can be that the level of the fourth version identifier is lower than the fifth version identifier, or the preset condition can be that the timestamp corresponding to the fourth version identifier is earlier than the timestamp corresponding to the fifth version identifier.

[0083] During the operation of the distributed system, the current node server may also receive broadcast messages sent by other node servers. The processing flow of the broadcast messages by each node server is the same, and the embodiments of the present invention will not be repeated here.

[0084] Optionally, a cache synchronization operation is performed for the current prefix field, including: obtaining second business data corresponding to the current prefix field stored in the database server; based on the current prefix field, determining the current cache partition from each candidate cache partition of the current node server, updating the third business data cached in the current cache partition to the second business data, and updating the fourth version identifier to the fifth version identifier.

[0085] Optionally, the cache data refresh method provided by the embodiment of the present invention may further include: in response to a cache synchronization instruction, obtaining a version information table stored in a database server; and performing a timed cache synchronization operation according to the version information table stored in the database server and the version information table stored in the current node server.

[0086] The cache synchronization instruction may be an instruction that is automatically triggered periodically. For example, the current node server may automatically trigger the cache synchronization instruction once every day.

[0087] During the operation of the distributed system, a node server may experience a network failure. During the network failure, the node server may miss the broadcast message of the message server. Based on this, in the embodiment of the present invention, a timed task can also be set, and each node server can ensure the data consistency of each node server by timing the triggering of cache synchronization instructions and executing the timing cache synchronization operation.

[0088] In an embodiment of the present invention, on the basis of the aforementioned embodiment, since the business types maintained by each candidate cache partition of each node server may have non-overlapping parts, based on this, in an embodiment of the present invention, the business types maintained by each candidate cache partition of each node server can be integrated at the database server. Then, when the current business data in the target cache partition of the current node server is changed based on the target prefix field, it is also necessary to synchronously change the business data corresponding to the target prefix field stored at the database server. In addition, in an embodiment of the present invention, the version identification of the business data currently stored in each candidate cache partition can also be recorded through a version information table. In this way, after other node servers perceive the refresh operation based on the broadcast message, they can implement a synchronous refresh operation by comparing the local version information table with the version information table of the database server to ensure the data consistency of each node server.

[0089] It should be noted that the cache data refresh method proposed in the embodiment of the present invention and the aforementioned embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the aforementioned embodiment, and the beneficial effects of the aforementioned embodiment are also applicable to this embodiment.

[0090] Taking the distributed system including the first node server, the second node server, and the third node server as an example, refer to Figure 5 The embodiment of the present invention provides a flow chart of another method for refreshing cache data. The method for refreshing cache data can be applied to a distributed system. The distributed system includes a first node server, a second node server, a third node server, a database server, and a message server. The method may include the following steps:

[0091] S510. When the first node server receives a cache refresh request, it determines a target cache partition from each candidate cache partition of the first node server based on the target prefix field carried in the cache refresh request, and refreshes the current business data cached in the target cache partition.

[0092] S520: When the cache refresh request carries target service data corresponding to the target prefix field, the first node server updates the target service data to the target cache partition.

[0093] S530: The first node server determines a first version identifier corresponding to the target prefix field from the version information table stored in the first node server, and adjusts the first version identifier to a second version identifier based on a preset adjustment rule.

[0094] S540: The first node server initiates a cache synchronization request carrying a target prefix field, target service data, and a second version identifier to the database server.

[0095] S550: The database server updates the first business data corresponding to the target prefix field stored in the database server to the target business data, and updates the third version identifier corresponding to the target prefix field in the version information table stored in the database server to the second version identifier.

[0096] S560: The first node server initiates a first broadcast request carrying a target prefix field to the message server.

[0097] S570: The message server sends a first broadcast message carrying a target prefix field to the second node server and the third node server.

[0098] S580. When the second node server receives the first broadcast message sent by the message server, the second node server determines the version identifier A corresponding to the target prefix field from the version information table stored in the second node server based on the target prefix field carried in the first broadcast message; and obtains the version information table stored in the database server, and determines the second version identifier corresponding to the target prefix field from the version information table stored in the database server.

[0099] S590. The second node server determines that the version of version identifier A is lower than the second version identifier, and obtains the target business data corresponding to the target prefix field stored in the database server, and based on the target prefix field, determines the target cache partition from each candidate cache partition of the second node server, updates the business data cached in the target cache partition to the target business data, and updates the version identifier A to the second version identifier.

[0100] S5100. The third node server obtains the version information table stored in the database server in response to the cache synchronization instruction, and performs a scheduled cache synchronization operation according to the version information table stored in the database server and the version information table stored in the third node server.

[0101] The third node server does not receive the first broadcast message sent by the message server due to a network failure.

[0102] It should be noted that the cache data refresh method proposed in the embodiment of the present invention and the aforementioned embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the aforementioned embodiment, and the beneficial effects of the aforementioned embodiment are also applicable to this embodiment.

[0103] Figure 6 This is a schematic diagram of the structure of a cache data refresh device provided in an embodiment of the present invention. The device can be configured in a current node server in a distributed system. The device can include: a determination module 610 and an execution module 620.

[0104] Exemplarily, the determination module 610 may execute S110 in the above method embodiment, and the execution module 620 may execute S120 in the above method embodiment.

[0105] Specifically, the determination module 610 is used to determine the target cache partition from the candidate cache partitions of the current node server based on the target prefix field carried in the cache refresh request when receiving the cache refresh request; wherein the target prefix field is used to uniquely represent a service type;

[0106] The execution module 620 is used to refresh the current business data cached in the target cache partition.

[0107] Optionally, in a possible implementation, the target prefix field includes business level identifiers arranged in sequence according to a preset sorting rule, and the determination module 610 is specifically used to: determine the target cache partition from the candidate cache partitions of the current node server based on the business level identifiers and the arrangement order of the business level identifiers.

[0108] Optionally, in another possible implementation, the determining module 610 is further configured to:

[0109] Based on each business level identifier and the arrangement order of each business level identifier, determine the query path of the prefix tree for the current node server; wherein each non-root node in the prefix tree corresponds to a business level identifier, and each leaf node in the prefix tree corresponds to a different candidate cache partition; according to the query path, search the prefix tree of the current node server for the target leaf node corresponding to the target prefix field, and determine the candidate cache partition corresponding to the target leaf node as the target cache partition.

[0110] Optionally, in another possible implementation, the execution module 620 is specifically configured to:

[0111] In the case where the cache refresh request carries the target service data corresponding to the target prefix field, the current service data cached in the target cache partition is updated to the target service data.

[0112] Optionally, in another possible implementation manner, the cache data refreshing device provided by the embodiment of the present invention may further include a sending module;

[0113] The determination module 610 is further configured to determine, after the execution module 620 updates the current business data cached in the target cache partition to the target business data, a first version identifier corresponding to the target prefix field from the version information table stored in the current node server, and adjust the first version identifier to a second version identifier based on a preset adjustment rule;

[0114] A sending module, used to initiate a cache synchronization request carrying a target prefix field, target business data, and a second version identifier to a database server, used to instruct the database server to update the first business data corresponding to the target prefix field stored in the database server to the target business data, and to update the third version identifier corresponding to the target prefix field in the version information table stored in the database server to the second version identifier;

[0115] The sending module is also used to initiate a first broadcast request carrying a target prefix field to the message server, and is used to instruct the message server to send a first broadcast message to other node servers in the distributed storage system, so that the other node servers perform cache synchronization operations on the target prefix field based on the version information table stored by the other node servers and the version information table stored by the database server.

[0116] Optionally, in another possible implementation, the determination module 610 is further used to: determine, in a case where a second broadcast message sent by the message server is received, a fourth version identifier corresponding to the current prefix field from a version information table stored in the current node server based on the current prefix field carried in the second broadcast message; obtain the version information table stored in the database server, and determine a fifth version identifier corresponding to the current prefix field from the version information table stored in the database server;

[0117] The execution module 620 is further configured to, when the determination module 610 determines that the fourth version identifier and the fifth version identifier meet a preset condition, perform a cache synchronization operation on the current prefix field.

[0118] Optionally, in another possible implementation, the execution module 620 is specifically configured to:

[0119] Acquire second business data corresponding to the current prefix field stored in the database server;

[0120] Based on the current prefix field, the current cache partition is determined from the candidate cache partitions of the current node server, the third service data cached in the current cache partition is updated to the second service data, and the fourth version identifier is updated to the fifth version identifier.

[0121] Optionally, in another possible implementation manner, the cache data refreshing device provided by the embodiment of the present invention may further include an acquisition module;

[0122] The acquisition module is used to obtain the version information table stored in the database server in response to the cache synchronization instruction; the execution module 620 is used to perform a scheduled cache synchronization operation according to the version information table stored in the database server and the version information table stored in the current node server.

[0123] Optionally, in another possible implementation manner, the cache data refreshing device provided by the embodiment of the present invention may further include a sending module;

[0124] A sending module is used to initiate a second broadcast request carrying a target prefix field to a message server after the execution module 620 performs a refresh operation on the current business data cached in the target cache partition, if the cache refresh request does not carry the target business data corresponding to the target prefix field, to instruct the message server to send a third broadcast message to other node servers in the distributed storage system, so that the other node servers perform a cache refresh operation on the target prefix field.

[0125] The cache data refresh device provided in the embodiment of the present invention belongs to the same inventive concept as the cache data refresh method provided in the aforementioned embodiments. For details that are not fully described in the embodiment of the cache data refresh device, reference can be made to the relevant contents of the aforementioned method embodiments, and the corresponding beneficial effects can also be referred to the beneficial effect analysis of the aforementioned method embodiments.

[0126] Figure 7 A schematic diagram of the structure of a cache data refresh device provided by an embodiment of the present invention. Figure 7 A block diagram of an exemplary cache data refreshing device 12 suitable for implementing the embodiments of the present invention is shown.

[0127] Figure 7 The displayed cache data refreshing device 12 is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0128] like Figure 7 As shown, the cache data refresh device 12 is in the form of a general computing device. The components of the cache data refresh device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).

[0129] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0130] The cache data refresh device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the cache data refresh device 12, including volatile and non-volatile media, removable and non-removable media.

[0131] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory (i.e., Figure 7 The cache data refresh device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0132] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0133] The cache data refresh device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the cache data refresh device 12, and / or any device that enables the cache data refresh device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the cache data refresh device 12 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 20. Figure 7 As shown, the network adapter 20 communicates with other modules of the cache data refresh device 12 via the bus 18. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with the cache data refresh device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0134] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, such as implementing the steps of the cache data refresh method provided in the embodiment of the present invention, the method comprising: upon receiving a cache refresh request, determining a target cache partition from each candidate cache partition of the current node server based on the target prefix field carried by the cache refresh request; wherein the target prefix field is used to uniquely represent a business type; and refreshing the current business data cached in the target cache partition.

[0135] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the cache data refresh method provided by any embodiment of the present invention.

[0136] The present embodiment provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the program implements the steps of a method for refreshing cache data as provided in the aforementioned embodiment of the present invention. The method includes: upon receiving a cache refresh request, determining a target cache partition from each candidate cache partition of the current node server based on a target prefix field carried in the cache refresh request; wherein the target prefix field is used to uniquely characterize a business type; and refreshing the current business data cached in the target cache partition.

[0137] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0138] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0139] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0140] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or a refresh device for cached data. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0141] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0142] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for refreshing cache data, characterized in that: Applied to a current node server in a distributed system, the method comprises: In the case of receiving a cache refresh request, determining a target cache partition from each candidate cache partition of the current node server based on a target prefix field carried in the cache refresh request; wherein the target prefix field is used to uniquely represent a service type; A refresh operation is performed on the current business data cached in the target cache partition.

2. The method for refreshing cache data according to claim 1, characterized in that: The target prefix field includes identifiers of various service levels arranged in sequence according to a preset sorting rule, and the target prefix field carried by the cache refresh request is used to determine a target cache partition from the candidate cache partitions of the current node server, including: Based on the service level identifiers and the arrangement order of the service level identifiers, the target cache partition is determined from the candidate cache partitions of the current node server.

3. The method for refreshing cache data according to claim 2, characterized in that: The determining the target cache partition from the candidate cache partitions of the current node server based on the service level identifiers and the arrangement order of the service level identifiers includes: Based on the business level identifiers and the arrangement order of the business level identifiers, determine the query path of the prefix tree for the current node server; wherein each non-root node in the prefix tree corresponds to a business level identifier, and each leaf node in the prefix tree corresponds to a different candidate cache partition; According to the query path, a target leaf node corresponding to the target prefix field is searched in the prefix tree of the current node server, and a candidate cache partition corresponding to the target leaf node is determined as the target cache partition.

4. The method for refreshing cache data according to claim 1, characterized in that: The refreshing operation on the current business data cached in the target cache partition includes: In a case where the cache refresh request carries the target service data corresponding to the target prefix field, the current service data cached in the target cache partition is updated to the target service data.

5. The method for refreshing cache data according to claim 4, characterized in that: After the current service data cached in the target cache partition is updated to the target service data, the method further includes: Determine a first version identifier corresponding to the target prefix field from the version information table stored in the current node server, and adjust the first version identifier to a second version identifier based on a preset adjustment rule; Initiate a cache synchronization request carrying the target prefix field, the target business data, and the second version identifier to the database server, to instruct the database server to update the first business data corresponding to the target prefix field stored by the database server to the target business data, and update the third version identifier corresponding to the target prefix field in the version information table stored by the database server to the second version identifier; A first broadcast request carrying the target prefix field is initiated to a message server, which is used to instruct the message server to send a first broadcast message to other node servers in the distributed system, so that the other node servers perform cache synchronization operations for the target prefix field based on the version information table stored by the other node servers and the version information table stored by the database server.

6. The method for refreshing cache data according to claim 5, characterized in that: The method further comprises: In the case of receiving the second broadcast message sent by the message server, based on the current prefix field carried by the second broadcast message, determining a fourth version identifier corresponding to the current prefix field from the version information table stored by the current node server; Obtaining a version information table stored in the database server, and determining a fifth version identifier corresponding to the current prefix field from the version information table stored in the database server; In the case where it is determined that the fourth version identifier and the fifth version identifier satisfy a preset condition, a cache synchronization operation is performed on the current prefix field.

7. The method for refreshing cache data according to claim 6, characterized in that: The performing of the cache synchronization operation for the current prefix field includes: Acquire second service data corresponding to the current prefix field stored in the database server; Based on the current prefix field, a current cache partition is determined from the candidate cache partitions of the current node server, the third business data cached in the current cache partition is updated to the second business data, and the fourth version identifier is updated to the fifth version identifier.

8. The method for refreshing cache data according to claim 5, characterized in that: The method further comprises: In response to a cache synchronization instruction, obtaining a version information table stored in the database server; A timed cache synchronization operation is performed according to the version information table stored in the database server and the version information table stored in the current node server.

9. The method for refreshing cache data according to any one of claims 1 to 8, characterized in that: After refreshing the current service data cached in the target cache partition, the method further includes: In the case that the cache refresh request does not carry the target business data corresponding to the target prefix field, a second broadcast request carrying the target prefix field is initiated to the message server, for instructing the message server to send a third broadcast message to other node servers in the distributed system, so that the other node servers perform a cache refresh operation for the target prefix field.

10. A cache data refresh device, characterized in that: A current node server configured in a distributed system, the device comprising: A determination module, configured to determine, upon receiving a cache refresh request, a target cache partition from candidate cache partitions of the current node server based on a target prefix field carried in the cache refresh request; wherein the target prefix field is used to uniquely characterize a service type; The execution module is used to refresh the current business data cached in the target cache partition.

11. A cache data refresh device, characterized in that: The cache data refreshing device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the cache data refresh method as described in any one of claims 1 to 9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the cache data refreshing method as described in any one of claims 1 to 9 is implemented.