[0028] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
[0029] figure 1 It is a flowchart of a distributed caching method according to an embodiment of the present invention. figure 1 The method is executed by the distributed cache system.
[0030] 101. Determine a first cache node according to a primary key value of metadata, and determine a second cache node according to a secondary key value of metadata.
[0031] 102. Store the metadata issued by the central storage node in the first cache node, store the location index of the metadata in the second cache node, and the location index of the metadata is used to indicate the address of the first cache node.
[0032] In the embodiment of the present invention, the first cache node and the second cache node are respectively determined according to the primary key value and the secondary key value of the metadata. The first cache node stores the metadata issued by the central storage node, and the second cache node The location index of the metadata is stored, and the location index of the metadata is used to indicate the address of the first cache node. Therefore, metadata can be accessed through the location index of the metadata, avoiding storing the same metadata in multiple cache nodes, thereby avoiding redundant storage of metadata, saving storage space, and ensuring consistent data access Sex.
[0033] It should be understood that the technical solution of the present invention can be used in a user-based network operation and maintenance system, and can also be used in a user data storage system or a large-scale form data storage system, which is not limited in the embodiment of the present invention.
[0034] It should be understood that the first cache node and the second cache node are different cache nodes. The number of second cache nodes may be one or more, which is not limited in the embodiment of the present invention. It should also be understood that the embodiment of the present invention does not limit which of the multiple key values of the metadata is determined as the primary key value. Optionally, the key value with the most queries may be determined as the primary key value. Key values other than the primary key value may be determined as secondary key values. It should be noted that there may be one or more secondary key values, which is not limited in the embodiment of the present invention.
[0035] Optionally, as an embodiment, in step 101, the first Hash value is obtained by Hashing according to the primary key value of the metadata, and the second Hash value is obtained by Hashing according to the secondary key value of the metadata. Hash value, the first Hash value corresponds to the first cache node, and the second Hash value corresponds to the second cache node. The following will also combine figure 2 The examples describe the embodiments of the present invention in detail.
[0036] Optionally, as another embodiment, after step 102, the distributed caching system may receive a first query request for metadata sent by the service processing node. The first query request for metadata carries a query key value, according to the query key value Look up metadata.
[0037] Specifically, the distributed cache system can determine the target cache node according to the query key value.
[0038] If the target cache node is the first cache node, the metadata can be found in the target cache node, that is, the metadata is hit in the first cache node. Further, reply the found metadata to the requester (service processing node).
[0039] If the metadata and the location index of any metadata are not found in the target cache node, the first query request of metadata may be sent to the central storage node, so that the central storage node can search for the metadata.
[0040] If the target location index is found in the target cache node, a redirection message is sent to the service processing node. The redirection message carries the target location index. Optionally, the service processing node may set a redirection query threshold. The service processing node judges the number of redirects according to the redirect message. When the number of times that the service processing node redirects searching metadata is less than the redirected query threshold, the service processing node may send a second query request to the distributed cache system, the second query request carrying the address of the cache node corresponding to the target location index. The distributed cache system may search for metadata in the cache node corresponding to the target location index according to the second query request. In the case where the target location index is the location index of the metadata, the distributed caching system may find the metadata in the first cache node, and further reply the found metadata to the service processing node. When the number of times that the service processing node redirects to search for metadata is greater than or equal to the redirected query threshold, the service processing node may no longer send a metadata query request to the distributed cache system, that is, the query fails. Therefore, the service processing node can prevent an endless loop of redirection by setting the maximum number of redirection query metadata.
[0041] The following will also combine image 3 The examples describe the embodiments of the present invention in detail.
[0042] Optionally, as another embodiment, when the storage address of the metadata changes, the distributed cache system may maintain the location index of the metadata stored in the second cache node, and the location index of the metadata is used to indicate the changed location index. The storage address of the metadata. Specifically, when the primary and secondary cache nodes are switched, for example, the first cache node (primary) fails, another cache node (standby) is used as the first cache node, and metadata is stored in the new first cache node, The location index of the metadata stored in the second cache node is updated, and the location index of the new metadata is used to indicate the address of the new first cache node.
[0043] In addition, when the metadata is modified, only the metadata of the first cache node needs to be updated, and there is no need to use a global lock to achieve the consistency of the metadata stored by multiple cache nodes, thereby reducing system complexity and processing delay.
[0044] figure 2 It is a schematic flowchart of a process of a method for determining a cache node according to an embodiment of the present invention. figure 2 The method is executed by the distributed cache system.
[0045] 201: Determine a first cache node corresponding to a primary key value of metadata.
[0046] 202. Store metadata in the first cache node.
[0047] For example, perform Hash hashing according to the primary key value Key 1 of the metadata to obtain the first Hash value Cache1, Cache 1 corresponds to the first cache node, and stores the metadata issued by the storage center storage node in the first hash value corresponding to Cache 1. One cache node.
[0048] 203. Determine cache nodes corresponding to other secondary key values of the metadata.
[0049] 204. Determine whether the cache node corresponding to the secondary key value is the first cache node.
[0050] Optionally, when the metadata has multiple secondary key values, the cache nodes corresponding to the secondary key values can be determined one by one.
[0051] For example, the Hash value obtained by Hashing according to the secondary key value Key 2 of the metadata is Cache2, and if Cache 2 corresponds to the first cache node, the process (206) is ended. If the Hash value obtained by Hashing according to the secondary key value Key 3 of the metadata is the second Hash value Cache 3, if the cache node corresponding to Cache 3 is not the first cache node, step 205 is executed.
[0052] 205. Store a location index of the metadata in the second cache node.
[0053] For example, the location index (Key 3, Cache 1) where metadata is stored in the cache node (second cache node) corresponding to Cache 3.
[0054] It should be understood that the above-mentioned examples are only illustrative, and not intended to limit the scope of the present invention.
[0055] Through the above solution, metadata can be accessed through the location index of metadata, avoiding storing the same metadata in multiple cache nodes, thereby avoiding redundant storage of metadata, saving storage space, and ensuring data access Consistency.
[0056] image 3 It is a schematic flowchart of a process of a metadata query method according to another embodiment of the present invention. image 3 The method is executed by the distributed cache system.
[0057] 301. Receive a first query request for metadata sent by a service processing node. The first query request carries the query key value.
[0058] 302: Determine the target cache node according to the query key value.
[0059] Optionally, if the target cache node determined according to the query key value is the first cache node and metadata is searched at the first cache node, step 303 may be performed. If the target location index is found in the target cache node determined according to the query key value, step 304 may be executed. If the metadata and the location index of any metadata are not found in the target cache node, step 305 may be executed.
[0060] The example of how to determine the target cache node according to the query key value is as described above, and will not be repeated here.
[0061] 303. Return the found metadata to the service processing node.
[0062] 304. Return a redirection message to the service processing node, where the redirection message carries the searched target location index.
[0063] 305. Send a first query request for metadata to the central storage node.
[0064] If metadata is found at the central storage node, the metadata can be returned to the business processing node.
[0065] Through the above solution, metadata can be accessed through the location index of metadata, avoiding storing the same metadata in multiple cache nodes, thereby avoiding redundant storage of metadata, saving storage space, and ensuring data access Consistency.
[0066] Figure 4 It is a schematic flowchart of a process of a method for querying metadata by a service processing node according to another embodiment of the present invention. Figure 4 The method is executed by the business processing node.
[0067] 401. Send a first metadata query request to the distributed cache system.
[0068] Querying metadata is the basis of business processing. When the business processing starts, the business processing node sends a first metadata query request to the distributed cache system, and the first query request carries the query key value.
[0069] 402: Receive a response message sent by the distributed cache system.
[0070] 403: Determine the type of the response message.
[0071] The distributed cache system receives the first query request in step 401, and finds metadata according to the first query request. The distributed cache system finds metadata for an example. image 3 example of. The response message returned by the distributed cache system received by the service processing node may be the found metadata or a redirect message.
[0072] Optionally, if the type of the response message is metadata, the service processing node may perform data processing (step 404). If the type of the response message is a redirect message, step 405 may be executed.
[0073] 405. The service processing node extracts the target location index in the redirect message.
[0074] 406. The service processing node judges whether the number of redirected searches for metadata is less than the redirected query threshold.
[0075] Optionally, if the number of times that the business processing node redirects to find metadata is less than the redirected query threshold, for example, when the business processing node searches for metadata, the number of times that it receives redirect messages is less than the redirected query threshold of 2, then step 407. If the number of times that the service processing node redirects to find metadata is greater than or equal to the redirection query threshold, for example, when the service processing node searches for metadata, the number of times it receives redirection messages is greater than or equal to the redirection query threshold 2, the service processing node can The request for querying metadata is no longer sent to the distributed cache system, that is, the query fails (step 408).
[0076] 407. The service processing node sends a second metadata query request to the distributed cache system.
[0077] The second query request carries the address of the cache node corresponding to the target location index. The distributed cache system may search for metadata in the cache node corresponding to the target location index according to the second query request. In the case where the target location index is the location index of the metadata, the distributed cache system may find the metadata in the first cache node, and further, the service processing node may receive the metadata returned by the distributed cache system.
[0078] Therefore, the service processing node can prevent an endless loop of redirection by setting the maximum number of redirection query metadata.
[0079] Figure 5 It is a structural block diagram of a distributed cache system according to an embodiment of the present invention. The distributed cache system 500 includes a determining unit 501, a first cache node 502, and a second cache node 503.
[0080] The determining unit 501 is configured to determine the first cache node 502 according to the primary key value of the metadata, and determine the second cache node 503 according to the secondary key value of the metadata.
[0081] The first cache node 502 determined by the determining unit 501 is used to store metadata delivered by the central storage node.
[0082] The second cache node 503 determined by the determining unit 501 is used to store a location index of metadata,
[0083] The location index of the metadata is used to indicate the address of the first cache node 502.
[0084] In the embodiment of the present invention, the first cache node and the second cache node are respectively determined according to the primary key value and the secondary key value of the metadata. The first cache node stores the metadata issued by the central storage node, and the second cache node The location index of the metadata is stored, and the location index of the metadata is used to indicate the address of the first cache node. Therefore, metadata can be accessed through the location index of the metadata, avoiding storing the same metadata in multiple cache nodes, thereby avoiding redundant storage of metadata, saving storage space, and ensuring consistent data access Sex.
[0085] It should be understood that the first cache node and the second cache node are different cache nodes. The number of second cache nodes may be one or more, which is not limited in the embodiment of the present invention.
[0086] Distributed cache system 500 can be implemented Figure 1 to Figure 4 The method involves various steps of the distributed caching system. To avoid repetition, it will not be described in detail.
[0087] Optionally, as an embodiment, the determining unit 501 is specifically configured to: perform Hash hashing according to the primary key value of the metadata to obtain the first Hash value, and perform Hash hashing according to the secondary key value of the metadata to obtain the second Hash value , The first Hash value corresponds to the first cache node, and the second Hash value corresponds to the second cache node.
[0088] Optionally, as another embodiment, the distributed caching system 500 may further include a receiving unit 504 configured to receive a first query request for metadata sent by a service processing node, and the first query request for metadata carries a query Key value. The determining unit 501 is also used for searching metadata according to the query key value.
[0089] Further, the determining unit 501 is specifically configured to determine the target cache node according to the query key value. The distributed cache system 500 may further include a sending unit 505, which is configured to send the metadata to the service processing node if the target cache node is the first cache node and metadata is found in the target cache node. The sending unit 505 is further configured to: if the target location index is found in the target cache node, send a redirection message to the service processing node, the redirection message carries the target location index, so that the service processing node can determine the number of redirections according to the redirection message. The sending unit 505 is further configured to: if the metadata and the location index of any metadata are not found in the target cache node, send a first metadata query request to the central storage node, so that the central storage node searches according to the first query request Metadata.
[0090] Furthermore, when the service processing node determines that the number of redirects is less than the redirect query threshold, the receiving unit 504 is further configured to receive a second query request of metadata sent by the service processing node according to the redirect message. The determining unit 501 is further configured to search for the metadata in the cache node corresponding to the target location index according to the second query request. In the case where the target location index is the location index of the metadata, the sending unit 505 is further configured to send the metadata found in the first cache node to the service processing node. Therefore, the service processing node can prevent an endless loop of redirection by setting the maximum number of redirection query metadata.
[0091] Optionally, as another embodiment, the determining unit 501 is further configured to: when the storage address of the metadata changes, maintain the location index of the metadata stored in the second cache node, and the location index of the metadata is used to indicate The storage address of the changed metadata.
[0092] In addition, when the metadata is modified, only the metadata of the first cache node needs to be updated, and there is no need to use a global lock to achieve the consistency of the metadata stored by multiple cache nodes, thereby reducing system complexity and processing delay.
[0093] Image 6 It is a schematic block diagram of a distributed cache system according to another embodiment of the present invention.
[0094] The embodiment of the present invention further provides an embodiment of a device for implementing each step and method in the above method embodiment. In this embodiment, the system 600 mainly includes a processor 601, a first buffer 602a and at least one second buffer 602b. The processor 601 controls the operation of the system 600, and the processor 601 may also be referred to as a CPU (Central Processing Unit, central processing unit). The first buffer 602a and the at least one second buffer 602b can provide instructions and data to the processor 601. The processor 601, the first buffer 602a and the at least one second buffer 602b, the transmitter 603 and the receiver 604 are coupled together by a bus system 610. The bus system 610 includes a data bus, a power bus, and a control bus. Bus and status signal bus. However, for clear description, various buses are marked as the bus system 610 in the figure.
[0095] The method disclosed in the foregoing embodiment of the present invention may be applied to the foregoing system 600. Among them, the processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the foregoing method can be completed by hardware integrated logic circuits in the processor 601 or instructions in the form of software.
[0096] The processor 601 is configured to determine the first buffer 602a according to the primary key value of the metadata, and determine the second buffer 602b according to the secondary key value of the metadata.
[0097] The first buffer 602a determined by the processor 601 is used to store metadata delivered by the central storage node.
[0098] The second buffer 602b determined by the processor 601 is used to store the location index of the metadata, and the location index of the metadata is used to indicate the address of the first buffer 602a.
[0099] In the embodiment of the present invention, the first buffer and the second buffer are respectively determined according to the primary key value and the secondary key value of the metadata. The metadata issued by the central storage node is stored in the first buffer, and the metadata issued by the central storage node is stored in the second buffer. The location index of the metadata is stored, and the location index of the metadata is used to indicate the address of the first buffer. Therefore, metadata can be accessed through the location index of metadata, avoiding storing the same metadata in multiple buffers, thereby avoiding redundant storage of metadata, saving storage space, and ensuring consistent data access Sex.
[0100] It should be understood that the first buffer and the second buffer are different buffers. The number of second buffers may be one or more, which is not limited in the embodiment of the present invention.
[0101] Distributed cache system 600 can realize Figure 1 to Figure 4 The method involves various steps of the distributed caching system. To avoid repetition, it will not be described in detail.
[0102] Optionally, as an embodiment, the processor 601 is specifically configured to: perform Hash hashing according to the primary key value of the metadata to obtain the first Hash value, and perform Hash hashing according to the secondary key value of the metadata to obtain the second Hash value , The first Hash value corresponds to the first buffer 602a, and the second Hash value corresponds to the second buffer 602b.
[0103] Optionally, as another embodiment, the receiver 604 is configured to receive a first query request for metadata sent by a service processing node, and the first query request for metadata carries a query key value. The processor 601 is also used for searching metadata according to the query key value.
[0104] Further, the processor 601 is specifically configured to determine the target cache according to the query key value. The transmitter 603 is configured to: if the target buffer is the first buffer 602a, and metadata is found in the target buffer, then the metadata is sent to the service processing node. The transmitter 603 is further configured to: if the target location index is found in the target buffer, send a redirection message to the service processing node, the redirection message carries the target location index, so that the service processing node can determine the number of redirections according to the redirection message. The transmitter 603 is also used to: if the metadata and the location index of any metadata are not found in the target buffer, send a first metadata query request to the central storage node, so that the central storage node searches according to the first query request Metadata.
[0105] Still further, when the service processing node determines that the number of redirects is less than the redirect query threshold, the receiver 604 is further configured to receive a second query request of metadata sent by the service processing node according to the redirect message. The processor 601 is further configured to search for the metadata in the buffer corresponding to the target location index according to the second query request. In the case where the target location index is the location index of the metadata, the transmitter 603 is further configured to send the metadata found in the first buffer 602a to the service processing node. Therefore, the service processing node can prevent an endless loop of redirection by setting the maximum number of redirection query metadata.
[0106] Optionally, as another embodiment, the processor 601 is further configured to: when the storage address of the metadata changes, maintain the location index of the metadata stored in the second buffer, and the location index of the metadata is used to indicate The storage address of the changed metadata.
[0107] In addition, when the metadata is modified, only the metadata of the first buffer buffer 602a needs to be updated, and there is no need to use a global lock to achieve the consistency of the metadata stored in multiple buffers, thereby reducing system complexity and processing time. Extension.
[0108] A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered as going beyond the scope of the present invention.
[0109] Those skilled in the art can clearly understand that, for convenience and concise description, the specific working process of the above-described system, device, and unit can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
[0111] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
[0112] In addition, the functional units in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
[0113] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solution of the present invention essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks or optical disks and other media that can store program codes. .