Optimization method and system for frequent Rpc pulling of non-real-time data
By configured the cache version number when caching the server, and the local cache and verification on the client, the interface performance loss and service pressure caused by frequent RPC pulling are solved, and efficient non -real -time data acquisition is achieved.
Patent Information
- Application Number
- CN202411502423.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-25
AI Technical Summary
Frequent non-real-time data Rpc pulling leads to increased interface performance loss and service pressure, affecting user experience.
When cache data is cached, the cache version number is configured according to the timestamp, and local cache is performed on the client. Check through the cache version number and interface call time to reduce the frequency of RPC calls on the service side.
Effectively reduce the loss of interface performance of RPC, improve the efficiency of non -real -time data in high -frequency access scenarios, and reduce service pressure.
Smart Images

Figure CN119376980A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an optimization method and system for frequent RPC pulling of non-real-time data. Background Art
[0002] With the rapid development of the Internet, data has exploded. Both users and enterprises pursue data processing speed and performance. If a website or interface is too slow, it will affect the user experience. Rpc (remote procedure call) is a technology that allows a program to execute code on a remote server locally. It is similar to a local procedure call, but the object of the operation is located on another computer. Rpc implements cross-network procedure calls by sending requests and receiving responses on the network, with good versatility and high flexibility. However, frequent and excessive Rpc calls will not only cause performance loss, but also increase the pressure on the service. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to propose an optimization method and system for frequent RPC pulling of non-real-time data, aiming to optimize the RPC pull call to reduce interface performance loss and reduce service pressure.
[0004] To achieve the above purpose, one aspect of an embodiment of the present application proposes an optimization method for frequent RPC pulling of non-real-time data, the method comprising:
[0005] When the server obtains the first data for caching, configuring a server cache version number for the first data according to the timestamp;
[0006] When the client calls the Rpc interface for the first time to request the required data from the server, the required data is pulled from the first data of the server through the Rpc interface;
[0007] Obtain the first data and the server cache version number, cache the first data and the server cache version number locally on the client as the second data and the client cache version number, and update the interface call time;
[0008] When the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds the preset time interval, the server cache version number is pulled from the server through the Rpc interface;
[0009] When the server cache version number is inconsistent with the client cache version number, pulling the required data from the first data of the server through the Rpc interface;
[0010] When the server cache version number is consistent with the client cache version, or the interval between the interface call time and the current time does not exceed a preset time interval, the required data is pulled from the second data.
[0011] In some embodiments, when the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds a preset time interval, before the step of pulling the server cache version number from the server through the Rpc interface, the method further includes the following steps:
[0012] In the configuration file of the Rpc interface of the client, a first cache key value is configured according to the timestamp of obtaining the first data by the server;
[0013] When the client calls the Rpc interface for the first time to request the required data from the server, the first cache key value is obtained and cached locally on the client, thereby obtaining a second cache key value;
[0014] When the client subsequently calls the Rpc interface to request the required data from the server, the first cache key value in the configuration file and the second cache key value stored locally are obtained;
[0015] When the first cache key value and the second cache key value are inconsistent, the judgment of the interface call time is skipped, and the server cache version number is directly pulled from the server through the Rpc interface.
[0016] In some embodiments, the method comprises the following steps:
[0017] Update the first cache key value according to the server data update status.
[0018] In some embodiments, after the step of pulling the required data from the first data of the server through the Rpc interface when the server cache version number is inconsistent with the client cache version number, the method further includes the following steps:
[0019] Update the second data and the client cache version number according to the first data and the server cache version number;
[0020] Update the interface call time.
[0021] In some embodiments, when caching is performed in the client, the caching mechanism of the Java virtual machine is used for caching.
[0022] In some embodiments, the method further comprises the following steps:
[0023] Configure the preset time interval based on the business scenario's requirements for data real-time performance.
[0024] In some embodiments, the client is a web client.
[0025] To achieve the above purpose, another aspect of the embodiment of the present application proposes an optimization system for frequent RPC pulling of non-real-time data, the system comprising:
[0026] The first module is used to configure a server-side cache version number for the first data according to a timestamp when the server obtains the first data for caching;
[0027] The second module is used to obtain the first data and the server cache version number when the client calls the Rpc interface for the first time to request the required data from the server, and cache the first data and the server cache version number locally on the client as the second data and the client cache version number, and update the interface call time;
[0028] The third module is used to pull the server cache version number from the server through the Rpc interface when the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds a preset time interval;
[0029] A fourth module is used to pull required data from the first data of the server through the Rpc interface when the cache version number of the server is inconsistent with the cache version number of the client;
[0030] The fifth module is used to pull the required data from the second data when the server cache version number is consistent with the client cache version, or the interval between the interface call time and the current time does not exceed a preset time interval.
[0031] It should be noted that, in some embodiments, the system may further include at least one of the following modules:
[0032] The seventh module is used to configure a first cache key value in the configuration file of the Rpc interface of the client according to the timestamp when the server obtains the first data; when the client calls the Rpc interface for the first time to request the required data from the server, the first cache key value is obtained and cached locally on the client to obtain a second cache key value; when the client subsequently calls the Rpc interface to request the required data from the server, the first cache key value in the configuration file and the second cache key value stored locally are obtained; when the first cache key value and the second cache key value are inconsistent, the judgment of the interface call time is skipped, and the server cache version number is directly pulled from the server through the Rpc interface.
[0033] The eighth module is used to update the second data and the client cache version number according to the first data and the server cache version number; and update the interface call time.
[0034] The ninth module is used to configure the preset time interval according to the real-time requirements of the business scenario for data.
[0035] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.
[0036] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0037] The embodiments of the present application include at least the following beneficial effects: The present application provides an optimization method and system for frequent RPC pulling of non-real-time data. When the server obtains the first data for caching, the solution configures the server cache version number for the first data according to the timestamp, and locally caches the data by calling the interface request on the client. By verifying the cache version number and the interface call time, the frequency of calling data from the server through Rpc can be reduced, the loss of Rpc to interface performance can be reduced, and the efficiency of obtaining non-real-time data in high-frequency access scenarios can be greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0039] Figure 1 It is a step diagram of an optimization method for frequent RPC pulling of non-real-time data provided by an embodiment of the present application;
[0040] Figure 2 It is a processing flow chart of an optimization method for frequent RPC pulling of non-real-time data provided by an embodiment of the present application;
[0041] Figure 3 It is a module schematic diagram of an optimization system for frequent RPC pulling of non-real-time data provided by an embodiment of the present application;
[0042] Figure 4 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0044] Although the functional modules are divided in the system schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first / S100", "second / S200", etc. in the specification, claims and the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0045] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0046] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0047] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0049] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0050] Rpc pull: Rpc (Remote Procedure Call) is a technology that allows a program to execute code on a remote server locally. It is similar to a local procedure call, but the object of the operation is located on another computer. Rpc pull refers to remote acquisition of data.
[0051] In related technologies, since data is often stored in the corresponding service, when the client wants to display data, it needs to obtain data from the server through Rpc. However, too many Rpc requests may cause interface performance loss, resulting in reduced data processing performance, and also increasing the pressure on the service.
[0052] In view of this, an embodiment of the present application provides an optimization method and system for frequent Rpc pulling of non-real-time data. This solution configures a server-side cache version number for the first data according to the timestamp when the server obtains the first data for caching, and calls the interface request on the client to cache the data locally. By verifying the cache version number and the interface call time, it can reduce the frequency of calling data from the server through Rpc, reduce the loss of Rpc to interface performance, and greatly improve the efficiency of obtaining non-real-time data in high-frequency access scenarios. In addition, the cache key value (cache Key) can also be configured. When there is data update, the cache key of the configuration file can be directly changed, and the current cache version number will be directly pulled by Rpc, skipping the verification of the interface call time, reducing the impact of data errors caused by no longer pulling through Rpc during access within the preset time.
[0053] An optimization method for frequent RPC pulling of non-real-time data provided in an embodiment of the present application relates to the field of computer technology. An optimization method for frequent RPC pulling of non-real-time data provided in an embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements an optimization method for frequent RPC pulling of non-real-time data, etc., but is not limited to the above forms.
[0054] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0055] Figure 1 This is an optional flow chart of an optimization method for frequent RPC pulling of non-real-time data provided by an embodiment of the present application. Figure 1 The method may include but is not limited to steps S100 to S600.
[0056] Step S100, when the server obtains the first data for caching, a server cache version number is configured for the first data according to the timestamp.
[0057] Step S200, when the client calls the Rpc interface for the first time to request the required data from the server, the required data is pulled from the first data of the server through the Rpc interface.
[0058] Step S300, obtaining the first data and the server cache version number, caching the first data and the server cache version number locally on the client as the second data and the client cache version number, and updating the interface call time.
[0059] Step S400, when the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds a preset time interval, the server cache version number is pulled from the server through the Rpc interface.
[0060] Step S500: When the server cache version number is inconsistent with the client cache version number, the required data is pulled from the first data of the server through the Rpc interface.
[0061] Step S600: when the server cache version number is consistent with the client cache version, or the interval between the interface call time and the current time does not exceed a preset time interval, the required data is pulled from the second data.
[0062] In steps S100 to S600 shown in the embodiment of the present application, when obtaining the first data for caching on the server, the server cache version number is configured for the first data according to the timestamp, and the data is locally cached by calling the interface request on the client, and the cache version number and the interface call time are verified, so that the frequency of calling data on the server through Rpc can be reduced, the loss of Rpc to interface performance can be reduced, and the efficiency of obtaining non-real-time data in high-frequency access scenarios can be greatly improved.
[0063] Before step S400 in some embodiments, the following steps S710 to S720 may be further included:
[0064] Step S710, in the configuration file of the Rpc interface of the client, configuring the first cache key value according to the timestamp of the first data obtained by the server;
[0065] Step S720, when the client calls the Rpc interface for the first time to request the required data from the server, the first cache key value is obtained and cached locally on the client, thereby obtaining a second cache key value;
[0066] Step S730, when the client subsequently calls the Rpc interface to request the required data from the server, the first cache key value in the configuration file and the second cache key value stored locally are obtained;
[0067] Step S740: When the first cache key value and the second cache key value are inconsistent, the judgment of the interface call time is skipped, and the server cache version number is directly pulled from the server through the Rpc interface.
[0068] Before step S400 in some embodiments, the following step S750 is further included:
[0069] Step S750: update the first cache key value according to the server data update status.
[0070] After step S500 in some embodiments, the method further includes the following steps S810-S820:
[0071] Step S810, updating the second data and the client cache version number according to the first data and the server cache version number;
[0072] Step S820: updating the interface calling time.
[0073] In some embodiments, when caching is performed in the client, the caching mechanism of the Java virtual machine is used for caching.
[0074] In some embodiments, the method further includes the step of configuring a preset time interval according to the business scenario's requirements for data real-time performance.
[0075] Below, in conjunction with an example of a specific scenario where a client obtains data from a server, the solution of the embodiment of the present application is described in detail and explained:
[0076] In an embodiment of the present application, a method for optimizing frequent RPC pulls of non-real-time data is provided. This method can be applied to the case of obtaining non-real-time data, optimizing the client to pull data from the server through the Rpc interface, reducing the frequency of Rpc pulls, reducing the loss of Rpc to interface performance, and improving the efficiency of obtaining non-real-time data in high-frequency access scenarios. Figure 2 , taking the web client as an example, specifically, it can be implemented as the following steps:
[0077] a. Build a data acquisition server, which can use Redis (remote dictionary service) as a cache storage database to cache data.
[0078] b. The server adds a server cache version number before the data cache. When the data is modified, the server cache version number needs to be changed.
[0079] c. A cache key is added to the configuration file of the client Rpc interface to determine whether to obtain the server cache version number of the server directly through Rpc when accessing the interface.
[0080] d. When the interface is accessed, determine whether the last time the web cache read the current interface has exceeded the preset time interval (for example, 30 seconds). If not, directly return to the web cache data. The preset time interval can be adjusted according to the business scenario's requirements for data real-time performance.
[0081] e. When the preset time interval has passed since the last access to the current interface, the server cache version number is obtained through Rpc. If the cache version number of the web side is the same as the cache version number of the server side, it proves that there is no data change and the data can be returned directly.
[0082] f. When the cache version number of the web side is different from that of the server side, it is necessary to initiate an Rpc to retrieve data from the server side again.
[0083] Furthermore, after obtaining the server data through Rpc for the first time, the JVM (Java Virtual Machine) cache mechanism can be used to cache the server's cache version number, data, and the current interface reading time (interface call time) on the web side so that it will not expire. When a new request arrives, the web-side cache can be used to determine whether it is necessary to obtain it again through Rpc, reducing the number of times Rpc obtains data.
[0084] Furthermore, within the preset time interval, normally the data will not be checked for changes. If there is indeed a relatively large data update, a cache key can be configured through the configuration file as shown in step c. When there is a data update, the cache key of the configuration file can be manually changed. In this way, the web side directly pulls the current cache version number through rpc, which can reduce the impact of errors caused by dirty data because access within the preset time interval is no longer through Rpc when it is clear that there is a data update.
[0085] Furthermore, the timestamp of data acquisition can be used as the server cache version number and as the prefix of the data cache key. When there is a data change, the server cache version number is updated. Using the timestamp as the version number is also more convenient for comparing the validity of data.
[0086] Furthermore, after reacquiring the data in step e, the version number and data of the local cache on the web side are updated according to the latest version number and data of the server-side cache, and the interface call time is updated.
[0087] In summary, the embodiments of the present application have at least the following beneficial effects:
[0088] 1. When obtaining the first data for caching on the server, the server cache version number is configured for the first data according to the timestamp, and the client calls the interface to request local caching of the data. By verifying the cache version number and the interface call time, the frequency of calling data on the server through Rpc can be reduced, the loss of Rpc to interface performance can be reduced, and the efficiency of obtaining non-real-time data in high-frequency access scenarios can be greatly improved.
[0089] 2. By configuring the cache key in the configuration file and modifying the cache key when the data is updated, you can reduce the impact of dirty data errors caused by no longer accessing through RPC within the preset time interval when there is a clear data update.
[0090] See also Figure 3 The embodiment of the present application also provides an optimization system for frequent RPC pulling of non-real-time data, which can implement the above-mentioned optimization method for frequent RPC pulling of non-real-time data. The system includes:
[0091] The first module 101 is used to configure a server cache version number for the first data according to a timestamp when the server obtains the first data for caching;
[0092] The second module 102 is used to pull the required data from the first data of the server through the Rpc interface when the client calls the Rpc interface for the first time to request the required data from the server;
[0093] The third module 103 is used to obtain the first data and the server cache version number, cache the first data and the server cache version number locally on the client as the second data and the client cache version number, and update the interface call time;
[0094] The fourth module 104 is used to pull the server cache version number from the server through the Rpc interface when the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds a preset time interval;
[0095] A fifth module 105 is configured to pull the required data from the first data of the server through the Rpc interface when the cache version number of the server is inconsistent with the cache version number of the client;
[0096] The sixth module 106 is used to pull the required data from the second data when the server cache version number is consistent with the client cache version, or the interval between the interface call time and the current time does not exceed a preset time interval.
[0097] It should be noted that, in some embodiments, the system may also include at least one of the following modules:
[0098] The seventh module is used to configure a first cache key value in the configuration file of the Rpc interface of the client according to the timestamp when the server obtains the first data; when the client calls the Rpc interface for the first time to request the required data from the server, the first cache key value is obtained and cached locally on the client to obtain a second cache key value; when the client subsequently calls the Rpc interface to request the required data from the server, the first cache key value in the configuration file and the second cache key value stored locally are obtained; when the first cache key value and the second cache key value are inconsistent, the judgment of the interface call time is skipped, and the server cache version number is directly pulled from the server through the Rpc interface.
[0099] The eighth module is used to update the second data and the client cache version number according to the first data and the server cache version number; and update the interface call time.
[0100] The ninth module is used to configure the preset time interval according to the real-time requirements of the business scenario for data.
[0101] It can be understood that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0102] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned optimization method for frequent RPC pulling of non-real-time data when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0103] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0104] See also Figure 4 , Figure 4 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0105] The processor 201 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0106] The memory 202 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 202 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 202, and the processor 201 calls and executes an optimization method for frequent RPC pulling of non-real-time data in the embodiment of this application;
[0107] Input / output interface 203, used to implement information input and output;
[0108] The communication interface 204 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0109] Bus 205 , which transmits information between various components of the device (e.g., processor 201 , memory 202 , input / output interface 203 , and communication interface 204 );
[0110] The processor 201 , the memory 202 , the input / output interface 203 and the communication interface 204 are connected to each other in communication within the device via the bus 205 .
[0111] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned optimization method for frequent RPC pulling of non-real-time data.
[0112] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0113] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0114] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0115] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0116] The system embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0117] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0118] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0119] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0120] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0121] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0123] If the integrated unit 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 application, or the part that contributes to the prior art, or all or 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 multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0124] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the rights of the present application is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application should be within the scope of the rights of the present application.
Claims
1. A method for optimizing frequent RPC pull of non-real-time data, characterized in that: The following steps are involved: When the server obtains the first data for caching, configuring a server cache version number for the first data according to the timestamp; When the client calls the Rpc interface for the first time to request the required data from the server, the required data is pulled from the first data of the server through the Rpc interface; Obtain the first data and the server cache version number, cache the first data and the server cache version number locally on the client as the second data and the client cache version number, and update the interface call time; When the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds the preset time interval, the server cache version number is pulled from the server through the Rpc interface; When the server cache version number is inconsistent with the client cache version number, pulling the required data from the first data of the server through the Rpc interface; When the server cache version number is consistent with the client cache version, or the interval between the interface call time and the current time does not exceed a preset time interval, the required data is pulled from the second data.
2. The method according to claim 1, characterized in that When the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds a preset time interval, before the step of pulling the server cache version number from the server through the Rpc interface, the method further includes the following steps: In the configuration file of the Rpc interface of the client, a first cache key value is configured according to the timestamp of obtaining the first data by the server; When the client calls the Rpc interface for the first time to request the required data from the server, the first cache key value is obtained and cached locally on the client, thereby obtaining a second cache key value; When the client subsequently calls the Rpc interface to request the required data from the server, the first cache key value in the configuration file and the second cache key value stored locally are obtained; When the first cache key value and the second cache key value are inconsistent, the judgment of the interface call time is skipped, and the server cache version number is directly pulled from the server through the Rpc interface.
3. The method according to claim 2, characterized in that The method comprises the following steps: Update the first cache key value according to the server data update status.
4. The method according to claim 1, characterized in that After the step of pulling the required data from the first data of the server through the Rpc interface when the server cache version number is inconsistent with the client cache version number, the method further includes the following steps: Update the second data and the client cache version number according to the first data and the server cache version number; Update the interface call time.
5. The method according to claim 1, characterized in that When caching is performed in the client, the caching mechanism of the Java virtual machine is used for caching.
6. The method according to claim 1, characterized in that The method further comprises the following steps: Configure the preset time interval based on the business scenario's requirements for data real-time performance.
7. The method according to claim 1, characterized in that The client is a web client.
8. An optimization system for frequent RPC pull of non-real-time data, characterized in that: include: The first module is used to configure a server-side cache version number for the first data according to a timestamp when the server obtains the first data for caching; The second module is used to pull the required data from the first data of the server through the Rpc interface when the client calls the Rpc interface for the first time to request the required data from the server; The third module is used to obtain the first data and the server cache version number, cache the first data and the server cache version number locally on the client as the second data and the client cache version number, and update the interface call time; The fourth module is used to pull the server cache version number from the server through the Rpc interface when the client subsequently calls the Rpc interface to request the required data from the server, and the interval between the interface call time and the current time exceeds a preset time interval; A fifth module is used to pull the required data from the first data of the server through the Rpc interface when the cache version number of the server is inconsistent with the cache version number of the client; The sixth module is used to pull the required data from the second data when the server cache version number is consistent with the client cache version, or the interval between the interface call time and the current time does not exceed a preset time interval.
9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store programs; The processor executes the program to implement the method according to any one of claims 1 to 7.
10. A computer storage medium storing a program executable by a processor, characterized in that: The program executable by the processor is used to implement the method according to any one of claims 1 to 7 when executed by the processor.
Citation Information
Patent Citations
Cache data acquisition method and related device
CN115344804A
Local cache synchronization method and system based on micro-service and version number mechanism
CN117171271A
Methods, devices and systems for maintaining consistency of metadata and data across data centers
US20180260409A1
System and method for offline-first application development
US20220239737A1