Data caching method and device applied to distributed deployment

By loading data in distributed server memory in advance and using shared memory version number for consistency verification, the problem of inefficient data acquisition and consistency in distributed deployment is solved, and efficient data acquisition and version management is achieved.

CN119088580APending Publication Date: 2024-12-06BEIJING GRIDSUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310656518.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-05
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

In distributed deployment, the existing cache technology has low data acquisition efficiency when transmitting big data objects due to network bandwidth and latency issues, and it is difficult to ensure data consistency in the memory of each server.

Method used

By loading target data in distributed server memory in advance and storing the remote version number of the latest version using shared memory, data version consistency verification is achieved. If the version is inconsistent, the latest version data will be reloaded to ensure the efficient data when calling the service Get it.

Benefits of technology

It improves the efficiency of data acquisition in memory of distributed servers, ensures data consistency, and reduces network transmission costs, solving the problem of low data acquisition efficiency in the prior art.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088580A_ABST
    Figure CN119088580A_ABST
Patent Text Reader

Abstract

The invention discloses a data caching method and device applied to distributed deployment, relates to the technical field of data processing, and can ensure the consistency of data stored in memories of distributed servers and improve the efficiency of data acquisition. According to the main technical scheme, the method comprises the steps of obtaining target data stored in a first server memory, wherein the target data corresponds to a first local version number; whether the first local version number is consistent with a remote version number stored in a shared memory or not is judged, the shared memory is deployed on a remote server, and the remote version number is the same as a second version number of latest version target data stored in a second server memory; the first server and the second server are servers corresponding to distributed nodes in the distributed system; if yes, determining that the target data is valid so as to support distributed service calling; and if not, determining that the target data is invalid, and re-loading the target data of the latest version into the memory of the first server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data caching method and device applied to distributed deployment. Background Art

[0002] In the field of software development, most of the core data of users must be stored on fixed media (such as disks, etc.), and they must be backed up to prevent data loss. In order to improve data reading efficiency, the data reading speed based on memory is dozens of times that of disk reading speed. Usually, cache technology is used to load the data stored on fixed media into memory in advance, so as to quickly read the required data from the memory.

[0003] At present, the application of caching technology in distributed deployment mainly loads data in advance into a remote machine with shared memory, so that in the distributed system, based on the response to user requests, no matter which server it is, it can load the same data into the shared memory, and even if the data in the shared memory is updated, the data obtained from the shared memory and loaded into the local memory of each server will always remain consistent.

[0004] However, although the consistency of data loaded into the memory of each distributed server is guaranteed, there is still a new problem: network data transmission is inevitably affected by factors such as network bandwidth and transmission delay. If the size of the loaded data object is very large, the data transmission cost will also increase, which will greatly reduce the efficiency of the distributed server memory in obtaining data. Summary of the invention

[0005] In view of this, the present application provides a data caching method and device applied to distributed deployment, so as to still load the target data into the distributed server memory in advance, and use the shared memory to store the remote version number of the latest version of the target data to implement version consistency verification of the target data in the memory of each distributed server, thereby not only ensuring the consistency of the data stored in the memory of each distributed server, but also greatly improving the efficiency of obtaining data when calling the service.

[0006] In order to achieve the above objectives, this application mainly provides the following technical solutions:

[0007] In a first aspect, the present application provides a data caching method applied to a distributed deployment, the method comprising:

[0008] Obtain target data stored in the memory of the first server, wherein the target data corresponds to a first local version number;

[0009] Determine whether the first local version number is consistent with the remote version number stored in the shared memory, wherein the shared memory is deployed on a remote server, the remote version number is the same as the second version number of the latest version of the target data stored in the memory of the second server, and the first server and the second server are servers corresponding to distributed nodes in the distributed system;

[0010] If they are consistent, the target data is determined to be valid to support distributed service calls;

[0011] If they are inconsistent, it is determined that the target data is invalid, and the latest version of the target data is reloaded into the memory of the first server.

[0012] In some modified implementations of the first aspect of the present application, the reloading of the latest version of the target data into the memory of the first server includes:

[0013] Deleting the target data and the first local version number in the memory of the first server;

[0014] Re-acquire the latest version of the target data and load it into the memory of the first server;

[0015] Based on the remote version number stored in the shared memory, a third local version number corresponding to the latest version target data in the first server memory is determined.

[0016] In some modified implementations of the first aspect of the present application, after reacquiring the latest version of the target data and loading it into the memory of the first server, the method further includes:

[0017] At the current system time, if it is determined that the remote version number does not exist in the shared memory, a version number corresponding to the latest version target data is generated based on the current system time as a new remote version number;

[0018] The new remote version number is added to the shared memory.

[0019] In some modified implementations of the first aspect of the present application, before determining that the target data is invalid, the method further includes:

[0020] If the target data is loaded into the first server memory for the first time, determining whether the loading operation time point occurs after the latest version of the target data is generated;

[0021] If so, it is determined that the target data loaded in the memory of the first server is the latest version of the target data, and the target data is determined to be valid;

[0022] The first local version number is updated according to the remote version number.

[0023] In some modified implementations of the first aspect of the present application, the method further includes:

[0024] During the life cycle corresponding to the target data, monitoring whether a modification operation on the target data occurs in a database of the distributed system;

[0025] If so, it is determined that the target data of various versions loaded in the memory of each distributed server is invalid.

[0026] In some modified implementations of the first aspect of the present application, the method further includes:

[0027] Deleting the remote version number stored in the shared memory;

[0028] Delete the target data loaded in the memory of the distributed server.

[0029] In some modified implementations of the first aspect of the present application, the method further includes:

[0030] Reloading the target data after the modification operation using the distributed server memory,

[0031] A corresponding local version number is added to the target data after the modification operation, and the local version number is synchronized to the shared memory to obtain a remote version number corresponding to the target data after the modification operation.

[0032] A second aspect of the present application provides a data caching device applied to a distributed deployment, the device comprising:

[0033] An acquiring unit, configured to acquire target data stored in a memory of the first server, wherein the target data corresponds to a first local version number;

[0034] A first judgment unit is used to judge whether the first local version number is consistent with a remote version number stored in a shared memory, wherein the shared memory is deployed on a remote server, the remote version number is the same as a second version number of the latest version of the target data stored in a memory of a second server, and the first server and the second server are servers corresponding to distributed nodes in a distributed system;

[0035] a determining unit, configured to determine that the target data is valid for supporting a distributed service call if the first local version number is consistent with the remote version number stored in the shared memory;

[0036] The determining unit is further configured to determine that the target data is invalid if the first local version number is inconsistent with the remote version number stored in the shared memory;

[0037] An execution unit is used to reload the latest version of the target data into the memory of the first server.

[0038] In some modified implementations of the second aspect of the present application, the execution unit includes:

[0039] A deletion module, used for deleting the target data and the first local version number in the memory of the first server;

[0040] An execution module, used for reacquiring the latest version of the target data and loading it into the memory of the first server;

[0041] A determination module is used to determine a third local version number corresponding to the latest version target data in the first server memory based on the remote version number stored in the shared memory.

[0042] In some modified implementations of the second aspect of the present application, after reacquiring the latest version of the target data and loading it into the first server memory, the execution unit further includes:

[0043] A generation module, configured to generate, based on the current system time, a version number corresponding to the latest version target data as a new remote version number if it is determined that the remote version number does not exist in the shared memory;

[0044] An adding module is used to add the new remote version number to the shared memory.

[0045] In some modified implementations of the second aspect of the present application, before determining that the target data is invalid, the device further includes:

[0046] A second judgment unit is used to judge whether the loading operation time point occurs after the latest version of the target data is generated if the target data is loaded into the first server memory for the first time;

[0047] The determining unit is further configured to determine that the target data loaded in the memory of the first server is the latest version of the target data if the loading operation time point occurs after the latest version of the target data is generated, and determine that the target data is valid;

[0048] An updating unit, configured to update the first local version number according to the remote version number.

[0049] In some modified implementations of the second aspect of the present application, the device further includes:

[0050] A monitoring unit, configured to monitor whether a modification operation on the target data occurs in a database of the distributed system during a life cycle corresponding to the target data;

[0051] The determining unit is further configured to determine that the target data of various versions loaded in the memory of each distributed server is invalid if a modification operation on the target data is monitored to occur in the database of the distributed system.

[0052] In some modified implementations of the second aspect of the present application, the device further includes:

[0053] A deleting unit, used for deleting the remote version number stored in the shared memory;

[0054] The deleting unit is further used to delete the target data loaded in the memory of the distributed server.

[0055] In some modified implementations of the second aspect of the present application, the device further includes:

[0056] The second execution unit is used to reload the target data after the modification operation by using the distributed server memory,

[0057] The adding unit is used to add the corresponding local version number to the target data after the modification operation, and synchronize the local version number to the shared memory to obtain the remote version number corresponding to the target data after the modification operation.

[0058] A third aspect of the present application provides a storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the data caching method applied to distributed deployment as described above.

[0059] A fourth aspect of the present application provides an electronic device, the device comprising at least one processor, and at least one memory and a bus connected to the processor;

[0060] Wherein, the processor and the memory communicate with each other through the bus;

[0061] The processor is used to call the program instructions in the memory to execute the data caching method applied to distributed deployment as described above.

[0062] By means of the above technical solution, the technical solution provided by this application has at least the following advantages:

[0063] The present application provides a data caching method and device applied to distributed deployment. In the current distributed deployment, a service will be deployed across machines to multiple servers. In order to improve data reading efficiency, the target data based on the service call can be stored in advance on each server. The present application will assign a local version number to the target data, and use the local version number of a remote server's shared memory as the shared remote version number, so that when the target data in any server's memory is updated to the latest version of the target data based on the call, the present application will also synchronously update the remote version number in the shared memory. In this way, if it is determined that the local version number of the target data in the memory of a server is inconsistent with the new remote version number, it indicates that the target data in the corresponding local memory is invalid and the latest version of the target data should be reloaded.

[0064] Compared with the prior art, the shared memory of the present application stores the remote version number instead of the pre-loaded target data, and the data volume of the remote version number is very small. Based on the transmission of the remote version number between each server, it is possible to efficiently complete the verification of whether the loaded data in each local memory is consistent, and because the target data is still loaded in the local memory, the target data can be directly obtained from the local memory when calling the service. The data caching solution provided by the present application solves the technical problem of low efficiency in obtaining target data when calling the service caused by the prior art solution. The present application can not only efficiently complete the verification of whether the target data stored in the memory of each distributed server is consistent, but also greatly improve the efficiency of obtaining the target data when calling the service.

[0065] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0067] Figure 1 A flow chart of a data caching method applied to distributed deployment provided in an embodiment of the present application;

[0068] Figure 2 A flow chart of another data caching method applied to distributed deployment provided in an embodiment of the present application;

[0069] Figure 3A block diagram of a data cache device applied to a distributed deployment provided in an embodiment of the present application;

[0070] Figure 4 A block diagram of another data cache device applied to a distributed deployment provided in an embodiment of the present application;

[0071] Figure 5 An electronic device for data caching in a distributed deployment provided in an embodiment of the present application. DETAILED DESCRIPTION

[0072] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0073] In today's distributed deployment, a service can be deployed across multiple servers. The cache technology used mainly loads data in advance to a remote server with shared memory. This way, when calling services on different servers, the same data can be obtained from the shared memory and loaded into the local memory, making the data loaded into the memory of different servers consistent.

[0074] However, the inventors found that for such a data caching solution, data transmission costs are required between the server and the shared memory. Especially when the size of the data object is large, this cost will increase accordingly, which will greatly reduce the efficiency of the local memory in obtaining data.

[0075] To this end, the inventors have discovered through research that in order to ensure that the required data can be quickly obtained when calling the service on the server, the preferred solution is still to load the data into the memory of each server in advance rather than the shared memory of the remote server, and the preferred solution is still to ensure that the data in the memory of each server is consistent, otherwise the data in the local memory will become invalid.

[0076] Based on the above considerations, the present application provides a data caching method applied to distributed deployment. This method can not only efficiently verify whether the memory storage data of each distributed server is consistent, but also greatly improve the efficiency of obtaining data when calling the service. The method is explained in detail below. Figure 1 , the present application embodiment provides the following specific steps:

[0077] 101. Obtain target data stored in a memory of a first server, where the target data corresponds to a first local version number.

[0078] In the distributed deployment of the embodiment of the present application, a service is deployed across machines to multiple servers, wherein the target data is the data required to call the service on the server. To facilitate the distinction between different servers, the embodiment of the present application uses the words "first" and "second" for identification, but those skilled in the art should know that the "first" and "second" are only used for identification and there is no order of precedence.

[0079] It should be further explained that multiple servers can be deployed in the distributed deployment provided in the embodiment of the present application. Among them, in order to avoid redundantly listing a large number of different servers, the embodiment of the present application uses a "first" identifier to verify whether the target data in the local memory is still valid (that is, as the "first server"), and uses a "second" identifier to store the latest version of the target data in the local memory (that is, as the "second server").

[0080] In order to facilitate calling services on the server, the embodiment of the present application is to load the target data into the local memory of the server in advance. For example, the target data is loaded in advance in the memory of two servers (the first server and the second server) in the distributed system. The version number refers to the identifier of the target data version. After the service is called on the server and the target data is obtained, if the target data is modified based on the user operation, it can be considered that the target data has changed a version, so that the new version number can be used to identify the called and modified target data. In addition, after the target data is loaded into the local memory for the first time, a unique initial local version number will be dynamically generated accordingly.

[0081] For example, for the target data pre-loaded in the memory of server A, the initial local version number can be identified as "0". If the target data is called on server A and modified based on user operations, the modified target data is stored in the memory of server A, and the corresponding local version number is increased by "1" and identified as "1". In the embodiments of the present application, it is not limited to using numbers such as "0, 1, 2......." to identify the local version number corresponding to the target data. The purpose is to be able to clearly represent: different versions of target data can be sorted according to the time sequence in which the target data is updated. Moreover, no matter which server memory the target data is loaded from, the local version number corresponding to each version of the target data should be consistent, so that the same local version number is used to determine that the content information of the target data loaded in the memory of each server is the same.

[0082] 102. Determine whether the first local version number is consistent with the remote version number stored in the shared memory.

[0083] Among them, the shared memory is deployed on a remote server. The embodiment of the present application uses such shared memory to store the version number of the latest version of the target data. To distinguish it from the name "local version number", the version number stored in the shared memory is called the "remote version number".

[0084] In the distributed deployment of the embodiment of the present application, if the target data in the memory of a server is called and modified, the corresponding local version number is updated (for example, cumulatively increased by "1") to obtain a new local version number, and the remote version number in the shared memory is further updated according to the new local version number, that is, for the new version of the target data, its new local version number and the new remote version number are consistent. In this iterative operation, when the target data in the memory of a server is called and modified, the local version number and the remote version number in the shared memory are updated accordingly.

[0085] According to this, in a preferred implementation, a key-value pair can be used to establish the relationship between "target data", "local version number" and "remote version number", for example, as:

[0086] {<key>:<value>}->

[0087] {<DATA_CACHE_KEY> :<Data,LOCAL_VERSION_NUM,REMOTE_VERSI ON_NUM>};

[0088] Therefore, based on such a key-value pair, when the target data in the server memory is modified based on the call and its local version number is upgraded to the new version number, the remote version number will be updated accordingly in the shared memory.

[0089] For the sake of clarity, the embodiment of the present application uses a server memory identified as the "second server" to store the latest version of the target data, and the corresponding local version number is also upgraded to the latest one, and accordingly the remote version number in the shared memory will also be updated synchronously.

[0090] For other servers in the distributed deployment (i.e., identified as the "first server"), it is necessary to compare the local version number of the target data in the corresponding local memory with the remote version number in the shared memory at this time. If they are consistent, it indicates that the target data in the memory of the first server is the latest version, but if they are inconsistent, it indicates that the target data in the memory of the first server has expired.

[0091] 103a. If it is determined that the first local version number of the target data stored in the memory of the first server is consistent with the remote version number stored in the shared memory, the target data is determined to be valid for supporting distributed service calls.

[0092] 103b. If it is determined that the first local version number of the target data stored in the memory of the first server is inconsistent with the remote version number stored in the shared memory, the target data is determined to be invalid, and the latest version of the target data is reloaded into the memory of the first server.

[0093] Regarding step 103a and step 103b, which are the judgment results of step 102, it should be noted that in order to clearly refer to the version numbers of the target data in the memory of different servers, the words "first" and "second" are used for identification, but technical personnel in this field should know that there is no order of precedence between these "first" and "second".

[0094] As described above, the embodiment of the present application provides a data caching method applied to distributed deployment. In the shared memory of the embodiment of the present application, what is stored is the remote version number instead of the target data loaded in advance, and the data volume of the remote version number is very small. Based on the transmission of the remote version number between each server, the verification of whether the loaded data in each local memory is consistent can be completed efficiently, and because the target data is still loaded in the local memory, the target data can be directly obtained from the local memory when calling the service. The data caching solution provided by the embodiment of the present application solves the technical problem of low efficiency in obtaining target data when calling a service caused by the existing technical solution. The embodiment of the present application can not only efficiently complete the verification of whether the target data stored in the memory of each distributed server is consistent, but also greatly improve the efficiency of obtaining target data when calling a service.

[0095] In order to explain the above embodiment in more detail, the embodiment of the present application also provides another data caching method applied to distributed deployment, such as Figure 2 As shown, the present application embodiment provides the following specific steps:

[0096] 201. Obtain target data stored in a memory of a first server, where the target data corresponds to a first local version number.

[0097] 202. Determine whether the first local version number is consistent with the remote version number stored in the shared memory.

[0098] Among them, the shared memory is deployed on the remote server, the remote version number is the same as the second version number of the latest version target data stored in the memory of the second server, and the first server and the second server are servers corresponding to the distributed nodes in the distributed system.

[0099] For the explanation of steps 201-202 in the embodiment of the present application, please refer to steps 101-102, which will not be repeated here.

[0100] 203a. If it is determined that the first local version number of the target data stored in the memory of the first server is consistent with the remote version number stored in the shared memory, the target data is determined to be valid for supporting distributed service calls.

[0101] In the distributed deployment provided in the embodiment of the present application, multiple servers can be deployed. Among these servers, the term "first server" refers to the server whose target data in the local memory is to be verified to be invalid, and the term "second server" refers to the server that stores the latest version of the target data in the local memory. And because the remote version number stored in the shared memory is consistent with the local version number of the latest version of the target data in the memory of the second server, the local version number of the target data in the first server is compared with the remote version number in the shared memory. If they are consistent, it indicates that the content information of the target data stored in the memory of the first server and the second server is consistent, so the target data in the memory of the first server is valid and can be used to support distributed service calls.

[0102] 203b. If it is determined that the first local version number of the target data stored in the memory of the first server is inconsistent with the remote version number stored in the shared memory, it is determined that the target data is invalid.

[0103] However, as explained in step 203a above, based on the comparison between the local version number of the target data in the "first server" and the remote version number in the shared memory, if they are inconsistent, it indicates that the content information of the target data stored in the memory of the "first server" and the "second server" is inconsistent. However, there are exceptions that require additional explanation, as follows:

[0104] If the target data is loaded into the memory of the first server for the first time, it is further determined whether the loading operation time point occurs after the latest version of the target data is generated; if so, it is determined that the target data loaded in the memory of the first server is the latest version of the target data, and the target data is determined to be valid; the first local version number is updated according to the remote version number.

[0105] For this exception, in short, when the target data is first loaded into the memory of the first server after the latest version of the target data is generated, based on the consistency of data transmission between each server and the database in the distributed deployment, the target data obtained from the database and loaded into the memory of the first server in advance is the latest version of the target data. However, since the initial local version number is assigned by default for the first time, it will be different from the remote version number in the shared memory, so it should be corrected in time, that is, synchronized to be consistent with the remote version number.

[0106] For example, scenario 1: Take servers A and B, where the target data is loaded in advance in A's memory, but the target data is not loaded in B's memory. A modifies the target data multiple times based on multiple calls to the service, so that the target data is equivalent to updating 3 versions. The local version number is exemplified as "3", and correspondingly, the remote version number of the latest version of the target data stored in the shared memory is also "3"; but after that, the target data is loaded in B's memory. In fact, the target data is already the latest version, but because the initial default local version number is "0", it is inconsistent with the remote version number. However, it should be clear that the latest version of the target data is loaded in B's memory at this time, so it is valid, so the local version number should be corrected to "3" at this time.

[0107] After explaining the above exceptions, the embodiment of the present application reloads the latest version of the target data into the memory of the first server after determining that the target data in the memory of the first server is invalid. The specific implementation steps are as follows: steps 204b, 205b, 206b, 207bc, 207bd and 208bd.

[0108] 204b. Delete the target data and the first local version number in the memory of the first server.

[0109] 205b. Re-acquire the latest version of the target data and load it into the memory of the first server.

[0110] As shown in steps 204b-205b, the embodiment of the present application is to re-acquire the latest version of target data required for the service from the database of the distributed system.

[0111] 206b. At the current system time, determine whether the remote version number exists in the shared memory.

[0112] For the embodiment of the present application, after determining that the target data in the memory of the first server is invalid, and the time difference between reacquiring the latest version of the target data, or before adding the latest local version number, the remote version number in the shared memory may be cleared, that is, the remote version number no longer exists in the shared memory. Therefore, the embodiment of the present application adopts step 206b to make a judgment first, and then determines which method to use to obtain the local version number corresponding to the latest version of the target data based on the judgment result.

[0113] 207bc. If the remote version number exists in the shared memory, determine the third local version number corresponding to the latest version of the target data in the memory of the first server based on the remote version number stored in the shared memory.

[0114] Since the remote version number stored in the shared memory is the version number corresponding to the latest version of the target data, if it is determined that the remote version number exists in the shared memory at the current system time, it can be synchronized directly based on the remote version number as the local version number corresponding to the latest version of the target data in the memory of the first server.

[0115] For example, scenario 2: Take servers A and B, the target data has been loaded in advance in the memory of A and the memory of B. After calling the service multiple times and modifying the target data multiple times on A, and after calling the service multiple times and modifying the target data multiple times on B, it should be noted that there is no conflict in modifying the target data in the embodiment of the present application, that is, there is no conflict each time the service is called on A and the service is called on B, so the local version number of the target data in the memory of A is exemplified as "3", and the local version number of the target data in the memory of B is exemplified as "4". It can be imagined that the last modification of the target data was caused by calling the service on B, so the remote version number in the shared memory is also "4".

[0116] In scenario 2, if the target data on A and the target data on B are inconsistent, the target data in A's memory will become invalid and the latest version of the target data will be reloaded, and the old local version number will be deleted and synchronized to the remote version number "4".

[0117] 207bd. At the current system time, if it is determined that the remote version number does not exist in the shared memory, a version number corresponding to the latest version of the target data is generated based on the current system time as a new remote version number.

[0118] 208bd. Add the new remote version number to the shared memory.

[0119] However, if it is determined that the remote version number does not exist in the shared memory, in order to ensure the uniqueness / non-reusability of the version number, such as avoiding duplication with any previous version number, a version number can be dynamically generated based on the current system time as the local version number of the latest version of the target data. And the newly generated version number is synchronized to the shared memory, so that the shared memory still stores the version number corresponding to the latest version of the target data.

[0120] In addition to the above, the remote version number in the shared memory is used to monitor whether the local version numbers in the memory of each server are consistent, so as to determine whether the target data in the local memory is invalid. In addition, the embodiment of the present application also provides monitoring of the entire life cycle of the target data, and specifically adopts the following implementation method:

[0121] During the life cycle corresponding to the target data, it is monitored whether a change operation on the target data occurs in the database of the distributed system. If so, it is determined that various versions of the target data loaded in the memory of each distributed server are invalid.

[0122] Furthermore, if the target data is invalid, the remote version number stored in the shared memory is deleted, and the target data loaded in the distributed server memory is deleted. It should be noted that after deleting the remote version number in the shared memory, it indicates that a new round of monitoring of the target data will be conducted again to determine whether the local memory is consistent.

[0123] Furthermore, the target data after the modification operation is reloaded using the distributed server memory, the corresponding local version number is added to the target data after the modification operation, and the local version number is synchronized to the shared memory to obtain the remote version number corresponding to the target data after the modification operation.

[0124] Furthermore, as a response to the above Figure 1 , Figure 2 The implementation of the method shown in the embodiment of the present application provides a data cache device applied to distributed deployment. The device embodiment corresponds to the aforementioned method embodiment. For ease of reading, the device embodiment will not repeat the details of the aforementioned method embodiment one by one, but it should be clear that the device in this embodiment can correspond to all the contents of the aforementioned method embodiment. The device is used to improve the cache performance in distributed deployment, specifically as follows Figure 3 As shown, the device comprises:

[0125] An acquiring unit 31 is used to acquire target data stored in the memory of the first server, where the target data corresponds to a first local version number;

[0126] A first judgment unit 32 is used to judge whether the first local version number is consistent with a remote version number stored in a shared memory, wherein the shared memory is deployed on a remote server, the remote version number is the same as a second version number of the latest version of the target data stored in a memory of a second server, and the first server and the second server are servers corresponding to distributed nodes in a distributed system;

[0127] A determination unit 33, configured to determine that the target data is valid for supporting a distributed service call if the first local version number is consistent with the remote version number stored in the shared memory;

[0128] The determining unit 33 is further configured to determine that the target data is invalid if the first local version number is inconsistent with the remote version number stored in the shared memory;

[0129] The execution unit 34 is used to reload the latest version of the target data into the memory of the first server.

[0130] Further, such as Figure 4 As shown, the execution unit 34 includes:

[0131] A deletion module 341, configured to delete the target data and the first local version number in the memory of the first server;

[0132] An execution module 342 is used to reacquire the latest version of the target data and load it into the memory of the first server;

[0133] The determination module 343 is used to determine a third local version number corresponding to the latest version target data in the first server memory based on the remote version number stored in the shared memory.

[0134] Further, such as Figure 4 As shown, after reacquiring the latest version of the target data and loading it into the first server memory, the execution unit 34 further includes:

[0135] A generating module 344 is used for generating a version number corresponding to the latest version target data based on the current system time as a new remote version number if it is determined that the remote version number does not exist in the shared memory at the current system time;

[0136] The adding module 345 is used to add the new remote version number to the shared memory.

[0137] Further, such as Figure 4 As shown, before determining that the target data is invalid, the device also includes:

[0138] The second judgment unit 35 is used to judge whether the loading operation time point occurs after the latest version of the target data is generated if the target data is loaded into the first server memory for the first time;

[0139] The determining unit 33 is further configured to determine that the target data loaded in the memory of the first server is the latest version of the target data if the loading operation time point occurs after the latest version of the target data is generated, and determine that the target data is valid;

[0140] The updating unit 36 ​​is configured to update the first local version number according to the remote version number.

[0141] Further, such as Figure 4 As shown, the device also includes:

[0142] A monitoring unit 37, configured to monitor whether a modification operation on the target data occurs in a database of the distributed system during a life cycle corresponding to the target data;

[0143] The determining unit 33 is further configured to determine that the target data of various versions loaded in the memory of each distributed server is invalid if a modification operation on the target data is monitored to occur in the database of the distributed system.

[0144] Further, such as Figure 4 As shown, the device also includes:

[0145] A deleting unit 38, configured to delete the remote version number stored in the shared memory;

[0146] The deleting unit 38 is further configured to delete the target data loaded in the memory of the distributed server.

[0147] Further, such as Figure 4 As shown, the device also includes:

[0148] The execution unit 34 is further configured to utilize the distributed server memory to reload the target data after the modification operation.

[0149] The adding unit 39 is used to add the corresponding local version number to the target data after the modification operation, and synchronize the local version number to the shared memory to obtain the remote version number corresponding to the target data after the modification operation.

[0150] In summary, the embodiments of the present application provide a data caching method and device applied to distributed deployment. Compared with the prior art, the embodiments of the present application store remote version numbers in shared memory instead of pre-loaded target data, and the data volume of the remote version numbers is very small. Based on the transmission of remote version numbers between each server, it is possible to efficiently complete the verification of whether the loaded data in each local memory is consistent, and because the target data is still loaded in the local memory, the target data can be directly obtained from the local memory when calling the service. The data caching solution provided by the embodiments of the present application solves the technical problem of low efficiency in obtaining target data when calling a service caused by the prior art solution. The embodiments of the present application can not only efficiently complete the verification of whether the target data stored in the memory of each distributed server is consistent, but also greatly improve the efficiency of obtaining target data when calling a service.

[0151] The data caching device applied to the distributed deployment includes a processor and a memory. The above-mentioned acquisition unit, first judgment unit, determination unit and first execution unit are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.

[0152] The processor contains a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the target data can still be loaded into the distributed server memory in advance by adjusting the kernel parameters, and the remote version number of the latest version of the target data is stored in the shared memory to implement the version consistency check of the target data in the memory of each distributed server, so as to not only ensure the consistency of the data stored in the memory of each distributed server, but also greatly improve the efficiency of obtaining data when calling the service.

[0153] An embodiment of the present application provides a storage medium on which a program is stored. When the program is executed by a processor, the data caching method applied to distributed deployment is implemented.

[0154] An embodiment of the present application provides a processor, which is used to run a program, wherein the data caching method applied to distributed deployment is executed when the program is running.

[0155] The present application embodiment provides an electronic device 4, such as Figure 5 As shown, the device includes at least one processor 41, and at least one memory 42 and a bus 43 connected to the processor 41; wherein the processor 41 and the memory 42 communicate with each other through the bus 43; the processor 41 is used to call the program instructions in the memory 42 to execute the above-mentioned data caching method applied to distributed deployment.

[0156] The device in this article can be a server, PC, etc.

[0157] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing the steps of the data caching method applied to a distributed deployment.

[0158] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0159] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.

[0160] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.

[0161] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0162] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0163] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0164] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A data caching method applied to distributed deployment, characterized in that: The method comprises: Obtain target data stored in the memory of the first server, wherein the target data corresponds to a first local version number; Determine whether the first local version number is consistent with the remote version number stored in the shared memory, wherein the shared memory is deployed on a remote server, the remote version number is the same as the second version number of the latest version of the target data stored in the memory of the second server, and the first server and the second server are servers corresponding to distributed nodes in the distributed system; If they are consistent, the target data is determined to be valid to support distributed service calls; If they are inconsistent, it is determined that the target data is invalid, and the latest version of the target data is reloaded into the memory of the first server.

2. The method according to claim 1, characterized in that The reloading of the latest version of the target data into the memory of the first server includes: Deleting the target data and the first local version number in the memory of the first server; Re-acquire the latest version of the target data and load it into the memory of the first server; Based on the remote version number stored in the shared memory, a third local version number corresponding to the latest version target data in the first server memory is determined.

3. The method according to claim 2, characterized in that After reacquiring the latest version of the target data and loading it into the first server memory, the method further includes: At the current system time, if it is determined that the remote version number does not exist in the shared memory, a version number corresponding to the latest version target data is generated based on the current system time as a new remote version number; The new remote version number is added to the shared memory.

4. The method according to claim 1, characterized in that Before determining that the target data is invalid, the method further includes: If the target data is loaded into the first server memory for the first time, determining whether the loading operation time point occurs after the latest version of the target data is generated; If so, it is determined that the target data loaded in the memory of the first server is the latest version of the target data, and the target data is determined to be valid; The first local version number is updated according to the remote version number.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: During the life cycle corresponding to the target data, monitoring whether a modification operation on the target data occurs in a database of the distributed system; If so, it is determined that the target data of various versions loaded in the memory of each distributed server is invalid.

6. The method according to claim 5, characterized in that The method further comprises: Deleting the remote version number stored in the shared memory; Delete the target data loaded in the memory of the distributed server.

7. The method according to claim 6, characterized in that The method further comprises: Reloading the target data after the modification operation by using the distributed server memory, A corresponding local version number is added to the target data after the modification operation, and the local version number is synchronized to the shared memory to obtain a remote version number corresponding to the target data after the modification operation.

8. A data cache device applied to distributed deployment, characterized in that: The device comprises: An acquiring unit, configured to acquire target data stored in a memory of the first server, wherein the target data corresponds to a first local version number; A first judgment unit is used to judge whether the first local version number is consistent with a remote version number stored in a shared memory, wherein the shared memory is deployed on a remote server, the remote version number is the same as a second version number of the latest version of the target data stored in a memory of a second server, and the first server and the second server are servers corresponding to distributed nodes in a distributed system; a determining unit, configured to determine that the target data is valid for supporting a distributed service call if the first local version number is consistent with the remote version number stored in the shared memory; The determining unit is further configured to determine that the target data is invalid if the first local version number is inconsistent with the remote version number stored in the shared memory; An execution unit is used to reload the latest version of the target data into the memory of the first server.

9. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the data caching method applied to distributed deployment according to any one of claims 1 to 7.

10. An electronic device, characterized in that: The device includes at least one processor, and at least one memory and a bus connected to the processor; Wherein, the processor and the memory communicate with each other through the bus; The processor is used to call the program instructions in the memory to execute the data caching method applied to distributed deployment as described in any one of claims 1 to 7.