A data processing method and device

By using request hash in the network request layer of the mobile client for unified management and cache sharing, the problem of high network request delay and failure rate of mobile clients in the wireless network environment is solved, data management efficiency is improved and data sharing between business modules is realized.

CN116033027BActive Publication Date: 2025-05-13BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211691316.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-27
Publication Date
2025-05-13
Estimated Expiration
2042-12-27

AI Technical Summary

Technical Problem

When mobile clients interact with data in a wireless network environment, there are problems such as high network request failure rate and large delay, and the network interface data cache management between service modules is inefficient and cannot be shared.

Method used

By implementing unified management of network interface data at the network request layer, data management and cache sharing are used using request hash. The specific steps include receiving a call request from the service layer, obtaining network request configuration information, determining the request hash, and obtaining or cacheing network interface data based on the hash and read cache policy information.

Benefits of technology

It improves data management efficiency, reduces network request latency and failure rate, and realizes network interface data cache sharing between service modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116033027B_ABST
    Figure CN116033027B_ABST
Patent Text Reader

Abstract

An embodiment of the present specification provides a data processing method and device, the method comprising: receiving a first call request for a first network interface from a business layer, wherein the first call request is used to indicate obtaining first network interface data required by the business layer, and the first call request carries at least current read cache policy information; obtaining network request configuration information corresponding to the first call request; based on the network request configuration information, determining a current request hash of a current network request to be initiated; based on the current request hash and the current read cache policy information, obtaining the first network interface data in a network request manner and / or in a local read cache manner, so as to feed back the first network interface data to the business layer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data processing method and device. Background Art

[0002] The client often needs to interact with the server to obtain data from the server and display it on the client's display interface. The network environment of the client installed on the mobile device (hereinafter referred to as the mobile client) is generally a wireless network environment (that is, the mobile client interacts with the server through the wireless network), and the wireless network often has the characteristics of low bandwidth and unstable connection, resulting in a high failure rate and high latency of the mobile client's network request (request for data from the server).

[0003] The current solution to the above problem is that each business module of the business layer of the mobile client can send an interface call request for calling certain network interfaces to the network request layer of the mobile client in advance, so as to pre-request network interface data of certain network interfaces from the corresponding server through the network request layer, and then each business module caches the pre-requested network interface data locally (hereinafter referred to as local) where the mobile client is located, and manages the cached network interface data. Then, when the business module needs to use the network interface data of certain network interfaces, it can first search whether there is corresponding network interface data in the local cache data. When it is determined that there is corresponding network interface data in the local cache data, it directly reads the corresponding network interface data from the local cache data and applies the network interface data to reduce the network request delay problem and failure rate for requesting network interface data; when it is determined that there is no corresponding network interface data in the local cache data, it sends the corresponding interface call request to the network request layer, and sends the network request for requesting the corresponding network interface data to the server through the network request layer, so as to obtain the corresponding network interface data from the server.

[0004] In the above process, each business module of the business layer needs to complete the caching and management of its pre-requested network interface data, which has low data management efficiency, and the network interface data cached between different business modules are isolated from each other and cannot be shared. Summary of the invention

[0005] One or more embodiments of the present specification provide a data processing method and device to achieve unified management of network interface data, improve data relationship efficiency, and achieve sharing of cached data among various business modules.

[0006] According to a first aspect, a data processing method is provided, comprising:

[0007] Receiving a first call request for a first network interface from a service layer, wherein the first call request is used to instruct to obtain first network interface data required by the service layer, and the first call request carries at least current read cache policy information;

[0008] Obtaining network request configuration information corresponding to the first call request;

[0009] Based on the network request configuration information, determine a current request hash of a current network request to be initiated;

[0010] Based on the current request hash and the current read cache policy information, the first network interface data is obtained in a network request manner and / or in a local read cache manner to feed back the first network interface data to the business layer.

[0011] According to a second aspect, there is provided a data processing device, comprising:

[0012] A receiving module, configured to receive a first call request for a first network interface from a business layer, wherein the first call request is used to indicate obtaining first network interface data required by the business layer, and the first call request carries at least current read cache policy information;

[0013] An acquisition module, configured to acquire network request configuration information corresponding to the first call request;

[0014] A first determination module is configured to determine a current request hash of a current network request to be initiated based on the network request configuration information;

[0015] The second determination module is configured to obtain the first network interface data in a network request manner and / or in a local read cache manner based on the current request hash and the current read cache policy information, so as to feed back the first network interface data to the business layer.

[0016] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect.

[0017] According to a fourth aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the first aspect is implemented.

[0018] According to the data processing method and device provided by the embodiments of this specification, the network request layer receives a first call request for a first network interface from the business layer, wherein the first call request is used to indicate obtaining the first network interface data required by the business layer, and the first call request carries at least the current read cache policy information; obtains the network request configuration information corresponding to the first call request; determines the current request hash of the current network request to be initiated based on the network request configuration information; obtains the first network interface data in a network request manner and / or in a local read cache manner based on the current request hash and the current read cache policy information, so as to feed back the first network interface data to the business layer. In the above process, after receiving the first call request for the first network interface carrying at least the current read cache policy information from the business layer, the network request layer determines the current request hash of the current network request to be initiated based on the network request configuration information corresponding to the obtained first call request. It can be understood that if the network request configuration information is the same, that is, the network request to be initiated is the same, the corresponding request hash is the same, and if the network request configuration information is different, that is, the network request to be initiated is different, the corresponding request hash is different. The network request layer obtains the first network interface data in a network request manner and / or in a local read cache manner based on the current request hash and the current read cache policy information, and then feeds back the first network interface data to the business layer. In the network request layer, unified management of network interface data is achieved through request hashes to improve data management efficiency. And considering the consistency judgment between the cached network interface data and the network request, that is, the same network request (i.e., network requests with the same request hash) hits the same network interface data, and different network requests (i.e., network requests with different request hashes) hit different network interface data, the network request layer can determine whether the network request to be initiated is the same based on the request hash, and then determine whether the network request to be initiated corresponds to the corresponding network interface (i.e., data), so as to avoid the isolation of the network interface data between the business models in the business layer to a certain extent, and realize the sharing of the locally cached network interface data between the business models in the business layer. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 A schematic diagram of an implementation framework of an embodiment disclosed in this specification;

[0021] Figure 2 A schematic diagram of a flow chart of a data processing method provided in an embodiment;

[0022] Figure 3A-3E Schematic diagrams of the process of obtaining data for different read cache strategy information provided in the embodiments;

[0023] Figure 4 A schematic diagram of a network request sending process provided by an embodiment;

[0024] Figure 5 A schematic block diagram of a data processing device provided in an embodiment;

[0025] Figure 6 A schematic block diagram of an electronic device provided in an embodiment. DETAILED DESCRIPTION

[0026] The technical solutions of the embodiments of this specification will be described in detail below with reference to the accompanying drawings.

[0027] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0028] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0029] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0030] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0031] The embodiments of this specification disclose a data processing method and device. The application scenarios and technical concepts of the method are first introduced as follows:

[0032] As mentioned above, the client installed on the mobile device (hereinafter referred to as the mobile client) is generally located in a wireless network environment (i.e., the mobile client interacts with the server through the wireless network), and the wireless network often has the characteristics of low bandwidth and unstable connection, resulting in the mobile client's network request (request for data from the server) having a high failure rate and delay.

[0033] The current solution to the above problem is that each business module of the business layer of the mobile client can send an interface call request for calling certain network interfaces to the network request layer of the mobile client in advance, so as to pre-request network interface data of certain network interfaces from the corresponding server through the network request layer, and then each business module caches the pre-requested network interface data locally (hereinafter referred to as local) where the mobile client is located, and manages the cached network interface data. Then, when the business module needs to use the network interface data of certain network interfaces, it can first search whether there is corresponding network interface data in the local cache data. When it is determined that there is corresponding network interface data in the local cache data, it directly reads the corresponding network interface data from the local cache data and applies the network interface data to reduce the network request delay problem and failure rate for requesting network interface data; when it is determined that there is no corresponding network interface data in the local cache data, it sends the corresponding interface call request to the network request layer, and sends the network request for requesting the corresponding network interface data to the server through the network request layer, so as to obtain the corresponding network interface data from the server.

[0034] In the above process, each business module of the business layer needs to complete the caching and management of its pre-requested network interface data, which makes data management inefficient. In addition, in some scenarios, some network interface data can be shared between different business modules, such as the avatar data and user nickname information of the logged-in user of the mobile client, which are common between different business modules. However, in the above process, since each business module completes the caching and management of its own network interface data, the network interface data cached locally between each business module is isolated from each other and cannot be shared.

[0035] In view of this, Figure 1 The following is a schematic diagram of an implementation scenario according to an embodiment disclosed in this specification. In this implementation scenario, the client may include a business layer related to the business and a network request layer that is at least used to send a network request to request the network interface data required by the business layer from the corresponding server, based on the functional distinction. The business layer may include business code modules corresponding to different business scenarios (referred to as business modules, such as Figure 1As shown in the business module 1, business module 2...business module N), the business scenario may include but is not limited to: the client's main page business scenario, the client's chat page business scenario, the client's certain object (such as recommended content, goods, users) details page business scenario, etc.

[0036] In this implementation scenario, in order to reduce the network request latency and failure rate for requesting network interface data, all or part of the business modules of the client's business layer can pre-request part of the network interface data, and obtain the corresponding network interface data through the network request layer, and cache the corresponding network interface data locally on the client device (hereinafter referred to as local). When the business module really needs to use the network interface data, it can directly read the corresponding network interface data from the local.

[0037] Specifically, in order to manage the network interface data of the network interface required by the business layer and to meet the different business scenario requirements of the business layer, the network request layer of the client can pre-set a variety of read cache strategy information (and write cache strategy information) so that the business module of the business layer can select the required read cache strategy information (and write cache strategy information) from them based on its own business scenario requirements, and send a call request for the network interface carrying at least the current read cache strategy information to the network request layer when it needs to pre-request network interface data or really needs to use the network interface data. Among them, the current read cache strategy information includes information that limits the way to obtain the corresponding network interface data, for example, including information that limits the way to obtain the corresponding network interface data by network request and / or local read cache.

[0038] Accordingly, the network request layer receives a request for a network interface (for example, Figure 1 The call request for the first network interface shown in the figure is called the first call request, which is used to indicate the interface data (hereinafter referred to as the first network interface data) required for obtaining the business layer (for example, the business module 1 therein), and the first call request carries at least the current read cache policy information.

[0039] The network request layer obtains the network request configuration information corresponding to the first call request, and the network request configuration information is the configuration information of the current network request to be initiated by the network request layer relative to the first call request. In one implementation, the network request configuration information may include at least one of the following information: request link, request type, request serialization method, request object, response type, and environment variable. Among them, the environment variable may refer to the environment variable of the business layer, such as the current login account information of the client. For a certain business module, the login account information is different, that is, the logged-in user is different, and the interface data of the corresponding network interface obtained is different. For example, for the business module corresponding to the main page business scenario of the client, the main page data obtained for account (ie user) A and the main page data obtained for account (ie user) B are different.

[0040] Then, the network request layer determines the current request hash of the current network request to be initiated based on the network request configuration information. Specifically, the network request layer can splice each information in the network request configuration information according to the preset information order to obtain the spliced ​​information, and then use the preset hash algorithm to perform hash calculation on the spliced ​​information to obtain the current request hash. For example: the network request configuration information may include a request link, a request type, a request serialization method, a request object, a response type, and an environment variable, and the preset information order is the order of the request link, the request type, the request serialization method, the serialized request object (for example, the serialized request object obtained by serializing the request object based on the request serialization method), the response type, and the environment variable. Accordingly, the network request layer can sequentially splice the request link, the request type, the request serialization method, the serialized request object, the response type, and the environment variable to obtain the spliced ​​information (a string of spliced ​​strings), and then use the preset hash algorithm (for example, the MD5 value algorithm) to perform hash calculation on the spliced ​​information to obtain the current request hash (i.e., the MD5 value).

[0041] Afterwards, the network request layer obtains the first network interface data based on the current request hash and the current read cache policy information by means of network request and / or local read cache, so as to feedback the required first network interface data to the business layer (the business module therein).

[0042] In one embodiment, if the first call request carries information indicating the first network interface data obtained by the cache, after the network request layer obtains the first network interface data, it can also cache the first network interface data locally, generate a cache record corresponding to the first network interface data, and record the correspondence between the current request hash and the cache record corresponding to the first network interface data. The cache record corresponding to the first network interface data can at least include the cache location of the first network interface data.

[0043] The first network interface data is cached locally so that after the network request layer receives a call request for the first network interface again, when the read cache policy information carried in the re-received call request includes an instruction to obtain data by reading the local cache, the network request layer can directly use the request hash calculated based on the network request configuration information corresponding to the re-received call request, and match the request hash (for example, the aforementioned current request hash) that is the same as the request hash calculated based on the network request configuration information corresponding to the re-received call request from the correspondence between the locally stored request hash and the cache record, and then obtain the corresponding cache record of the first network interface data, and based on the cache record of the first network interface data, obtain the first network interface data from the local cache, and feed it back to the corresponding business module in the business layer to reduce the delay and failure rate of its network requests.

[0044] In one case, the information carried in the first call request indicating the first network interface data obtained by the cache may be a period value of a maximum life cycle, and when the period value is not 0, it can be determined that the information carried in the first call request indicating the first network interface data obtained by the cache. The period value of the maximum life cycle may represent the maximum validity period of the corresponding network interface data in the local cache.

[0045] In the above process, the network request layer realizes unified management of network interface data through request hash, thereby improving data management efficiency. And considering the consistency judgment between the cached interface data and the network request, that is, the same network request (i.e., network request with the same request hash) hits the same network interface data, and different network requests (i.e., network requests with different request hashes) hit different network interface data, the network request layer can determine whether the network request to be initiated is the same based on the request hash, and then determine whether the network request to be initiated corresponds to the corresponding network interface (i.e., data), so as to avoid the isolation of the network interface data between the business models in the business layer to a certain extent, and realize the sharing of the locally cached network interface data between the business models in the business layer.

[0046] The data processing method and device provided in this specification are described in detail below in conjunction with specific embodiments.

[0047] Figure 2A flow chart of a data processing method in one embodiment of the present specification is shown. The method can be implemented by a target program, and the target program can be set in the network request layer of the target client, so that the network request layer can implement the data processing method provided in the embodiment of the present specification. The target client can also include a business layer related to the business, which is used to provide corresponding business services to users of the target client. The business layer can include business code modules (referred to as business modules) corresponding to different business scenarios. The business scenarios may include but are not limited to: the client's home page business scenario, the client's chat page business scenario, the client's certain objects (such as recommended content, goods, users) details page business scenario, etc. The network request layer can also respond to a call request for a network interface sent by any business module of the business layer, and send a network request to request the network interface data required by any business module from the corresponding server. The target client can be installed in an electronic device, and the electronic device can be implemented by any device, equipment, platform, device cluster, etc. with computing and processing capabilities. In one implementation, the electronic device can be a mobile device or a non-mobile device. As Figure 2 As shown, the method includes the following steps: S210-S240:

[0048] In step S210, a first call request for the first network interface is received from the business layer. The first call request is used to indicate the acquisition of the first network interface data required by the business layer, and the first call request carries at least the current read cache policy information. When any business module of the business layer requests network interface data, it is necessary to send a call request for the corresponding network interface to the network request layer. Correspondingly, the target program set in the network request layer can receive a call request (referred to as a first call request) for the network interface (for example, the first network interface) from the business layer. The first network interface can be any network interface that can be called by the business layer (that is, any network interface that can be managed by the network request layer), and the first call request can be an interface call request triggered by any business module of the business layer for calling the first network interface, thereby obtaining the data of the first network interface (that is, the first network interface data) provided by the server corresponding to the target client.

[0049] In one implementation, the timing for the business module to request network interface data (i.e., send a first call request) may be before the business module actually needs to use the corresponding network interface data (i.e., the aforementioned pre-request network interface data), or when the business module actually needs to use the corresponding network interface data.

[0050] The current read cache policy information carried by the first call request may be the read cache policy information selected by the business module of the business layer according to its own business scenario requirements. In one embodiment, the current read cache policy information may be one of the following policies: the first, requestOnly: only obtain data through network request, not by reading local cache; the second, cacheOnly: only obtain data by reading local cache, not by network request; the third, requestFirst: first obtain data through network request, if data acquisition fails, obtain data by reading local cache; the fourth, cacheFirst: first obtain data by reading local cache, if data acquisition fails, obtain data by network request; the fifth, parallel: obtain data by both network request and reading local cache.

[0051] The above five types of read cache policy information are pre-stored by the target program and can be selected by each business module of the business layer according to its own business scenarios and needs. Different read cache policy information is set to cope with different business scenarios and the usage requirements of different business modules of the business layer. The current read cache policy information carried in the first call request is: the policy information selected by the business module sending the first call request from the five types of read cache policy information according to its own business scenario.

[0052] Then, in step S220, the network request configuration information corresponding to the first call request is obtained. The network request configuration information is the configuration information of the network request (i.e., the subsequent current network request) to be initiated by the target program (i.e., the network request layer) in response to the first call request. In one embodiment, the network request configuration information may include at least one of the following information: request link, request type, request serialization method, request object, response type, and environment variable. Among them, the request type may include various request types based on the HTTP network protocol such as POST request type and GET request type, and may also include various request types based on other network protocols. The request serialization method may include conventional serialization methods, such as JSON, XML, FORM, PB, and other serialization methods. The environment variable may refer to the environment variable of the business layer, such as the current login account information of the client. For a certain business module, the login account information is different, that is, the logged-in user is different, and the interface data of the corresponding network interface obtained is different. For example, for the business module corresponding to the home page business scenario of the client, the home page data obtained for account (i.e., user) A and the home page data obtained for account (i.e., user) B are different. The request link may include a request URL (Uniform Resource Locator) and may also include parameters that need to be passed, namely, query parameters.

[0053] In one implementation, the network request configuration information may be carried in the first call request and passed to the target program by the business layer. In another implementation, the network request configuration information may include static configuration information and dynamic configuration information. The static configuration information may include, for example: the request URL, request type, request serialization method, request object, response type, etc. in the request link. After the network interface to be called is determined, the configuration information can be determined. The parameters to be passed in the request link, i.e., the query parameters, need to be changed according to the actual situation of the business module, and need to be immediately transmitted by the business module, which is dynamic configuration information.

[0054] For the static configuration information, the target program may obtain it from a preset configuration file, which includes static configuration information set for each network interface (ie, for a call request for each network interface).

[0055] For dynamic configuration information, the first call request may carry such dynamic configuration information, and the corresponding target program may parse the dynamic configuration information in the network request configuration information from the first call request to obtain the network request configuration information corresponding to the first call request.

[0056] For the login account information in the environment variable, if the login user remains unchanged, the login account information in the environment variable will also remain unchanged. Accordingly, the login account information in the environment variable can be considered as static configuration information, which can be configured in the configuration file so that it can be obtained from the configuration file. In addition, it can also be carried in the first call request, and the target program can be directly parsed from the first call request.

[0057] Afterwards, in step S230, based on the network request configuration information, the current request hash of the current network request to be initiated is determined. In this step, the target program can perform hash calculation on the network request configuration information based on a preset hash algorithm to obtain the current request hash. In one embodiment, in step S230, the following steps 11-12 may be included, wherein, in step 11, each information in the network request configuration information is spliced ​​in accordance with a preset information order to obtain spliced ​​information; and in step 12, a preset hash algorithm is used to perform hash calculation on the spliced ​​information to obtain the current request hash.

[0058] The preset information order can be pre-configured, and the preset information order is the same for each call request. In one implementation, if the network request configuration information includes a request link, a request type, a request serialization method, a request object, a response type, and an environment variable, and the preset information order is the order of the request link, the request type, the request serialization method, the serialized request object (for example, the serialized request object based on the request serialization method), the response type, and the environment variable. Accordingly, the target program can sequentially splice the request link, the request type, the request serialization method, the serialized request object, the response type, and the environment variable to obtain the spliced ​​information (a string of spliced ​​characters), and then use a preset hash algorithm (for example, an MD5 value algorithm) to perform a hash calculation on the spliced ​​information to obtain the current request hash (i.e., the MD5 value).

[0059] After obtaining the current request hash, in step S240, based on the current request hash and the current read cache policy information, the first network interface data is obtained by network request and / or by local read cache to feed back the first network interface data to the business layer.

[0060] The current read cache policy information may include information defining how to obtain data (e.g., network request and / or local cache reading), i.e., how to obtain data from the first network interface. Based on the current request hash, it can be determined how to read the local cache and how to make a network request.

[0061] In one embodiment, when the current read cache policy information carried by the first call request is to obtain data only through network requests and not by reading local cache, the target program determines that it needs to obtain the first network interface data through network requests. Accordingly, Figure 3A As shown, after the target program obtains the first call request, the current request hash of the current network request to be initiated is determined based on the network request configuration information corresponding to the obtained first call request. Afterwards, the current network request (the current network request may carry the network request configuration information and the current request hash) is sent to the server corresponding to the target client. Then, if the target program receives the first network interface data based on the feedback of the current network request from the server, the target program may feed back the first network interface data to the business module (also referred to as the caller) in the business layer that sends the first call request. If the target program does not receive the first network interface data from the server, it sends the first call request to the business module in the business layer, and feeds back error information indicating that the first network interface data has not been obtained.

[0062] In one implementation, if the first call request also carries information indicating caching the first network interface data (i.e., write cache policy information), accordingly, if the target program receives the first network interface data based on the current network request feedback from the server, the target program can cache the first network interface data in a local preset storage space, and then generate a cache record corresponding to the first network interface data, and store the correspondence between the current request hash and the cache record corresponding to the first network interface data. So that when the target program receives a call request for the first network interface again in the future, and the read cache policy information carried therein includes an instruction to obtain data by reading the local cache, the corresponding first network interface data can be read from the local based on the corresponding calculated request hash. Among them, the cache record corresponding to the first network interface data includes at least the local cache location of the first network interface data.

[0063] In one implementation, the information carried by the first call request indicating the cache of the first network interface data may be a period value of the maximum life cycle. When the period value is not 0, it is determined that the first call request indicates that the acquired first network interface data needs to be cached. Accordingly, when the first network interface data is cached locally, the maximum life cycle of the cached first network interface data needs to be set to the period value. At this time, the cache record corresponding to the first network interface data may also include: the cache time of the first network interface data, so that the validity period of the locally cached first network interface data can be determined based on the cache time and the period value of the maximum life cycle. In addition, the cache record corresponding to the first network interface data may also include a result indicating whether the cached first network interface data has expired, based on which it can be directly determined whether the locally cached first network interface data has expired. In one case, the cache record corresponding to the first network interface data may also include the amount of cache space for the first network interface data, so as to facilitate the target program to manage the locally cached first network interface data.

[0064] In another embodiment, when the current read cache policy information carried by the first call request is to obtain data only by reading the local cache and not by network request, the target program determines that it needs to obtain the first network interface data by reading the local cache. Figure 3BAs shown, after the target program obtains the first call request, the current request hash of the current network request to be initiated is determined based on the network request configuration information corresponding to the first call request obtained. Afterwards, the local cache is searched based on the current request hash, that is, based on the current request hash and the cache records corresponding to the locally stored historical request hashes, it is determined whether the first cache record corresponding to the current request hash is stored locally, that is, it is determined whether the locally stored historical request hashes contain the same historical request hash as the current request hash. If it is determined to be contained, the cache record corresponding to the historical request hash that is the same as the current request hash is determined as the first cache record corresponding to the current request hash, and then the first network interface data is obtained based on the cache position in the first cache record, and then the first network interface data is fed back to the business module that sends the first call request in the business layer. If it is determined that the locally stored historical request hashes do not contain the same historical request hash as the current request hash, it can be determined that the first network interface data does not exist in the local cache, and accordingly, the target program feeds back to the business layer (the business module that sends the first call request) an error message indicating that the first network interface data has not been obtained.

[0065] In another implementation, after the target program determines the first cache record corresponding to the current request hash, it can also directly feed back the first cache record to the business module that sends the first call request in the business layer, so that it can obtain the first network interface data based on the cache location in the first cache record.

[0066] In another embodiment, when the current read cache policy information carried by the first call request is to first obtain data by means of a network request, and if the data acquisition fails, obtain data by reading the local cache, the target program determines that it is necessary to first obtain the first network interface data by means of a network request, and if the acquisition fails, obtain the first network interface data by reading the local cache. Figure 3C As shown, after the target program obtains the first call request, it determines the current request hash of the current network request to be initiated based on the network request configuration information corresponding to the obtained first call request. After that, the current network request (the current network request may carry the network request configuration information and the current request hash) is sent to the server corresponding to the target client. Then, if the target program receives the first network interface data based on the feedback of the current network request from the server, the target program can feed back the first network interface data to the business module in the business layer that sends the first call request.

[0067] If the target program does not receive the first network interface data from the server, it can determine whether the first cache record corresponding to the current request hash is stored locally based on the current request hash and the cache records corresponding to the historical request hashes stored locally, that is, determine whether the historical request hash stored locally contains the same historical request hash as the current request hash. If it is determined to be contained, the cache record corresponding to the historical request hash that is the same as the current request hash is determined to be the first cache record corresponding to the current request hash, and then based on the cache position in the first cache record, the first network interface data is obtained, and the first network interface data is fed back to the business module that sends the first call request in the business layer. If it is determined that the historical request hashes stored locally do not contain the same historical request hash as the current request hash, it can be determined that the first network interface data does not exist in the local cache. Accordingly, the target program feeds back to the business layer (the business module that sends the first call request) an error message indicating that the first network interface data has not been obtained.

[0068] In another embodiment, when the current read cache policy information carried by the first call request is to first obtain data by reading the local cache, and if the data acquisition fails, then obtain the data by network request, then the target program determines that it is necessary to first obtain the first network interface data by reading the local cache, and if the acquisition fails, then obtain the first network interface data by network request. Figure 3D As shown, after the target program obtains the first call request, it determines the current request hash of the current network request to be initiated based on the network request configuration information corresponding to the obtained first call request. Afterwards, based on the current request hash and the cache records corresponding to the locally stored historical request hashes, it is determined whether the first cache record corresponding to the current request hash is stored locally, that is, it is determined whether the locally stored historical request hashes contain the same historical request hash as the current request hash. If it is determined to be contained, the cache record corresponding to the historical request hash that is the same as the current request hash is determined as the first cache record corresponding to the current request hash. Afterwards, based on the cache position in the first cache record, the first network interface data is obtained, and the first network interface data is fed back to the business module in the business layer that sends the first call request.

[0069] If it is determined that the historical request hash stored locally does not contain the same historical request hash as the current request hash, it can be determined that the first network interface data does not exist in the local cache, and then the target program sends the current network request to the server corresponding to the target client. If the target program receives the first network interface data based on the feedback of the current network request from the server, the target program can feed back the first network interface data to the business module that sent the first call request in the business layer. If the first network interface data is not received from the server, the business module that sent the first call request in the business layer will be fed back with error information indicating that the first network interface data has not been obtained.

[0070] In another embodiment, when the current read cache policy information carried by the first call request is to obtain data by both a network request and a local cache, the target program determines that it needs to obtain the first network interface data by both a local cache read and a network request. Figure 3E As shown, after the target program obtains the first call request, it determines the current request hash of the current network request to be initiated based on the network request configuration information corresponding to the obtained first call request. On the one hand, the target program sends the current network request to the server corresponding to the target client. If the target program receives the first network interface data fed back based on the current network request from the server, the first network interface data is fed back to the business module in the business layer that sent the first call request. If the first network interface data is not received from the server, the business module that sends the first call request in the business layer is fed back with error information indicating that the first network interface data has not been obtained.

[0071] On the other hand, the target program determines whether the first cache record corresponding to the current request hash is stored locally based on the current request hash and the cache records corresponding to the historical request hashes stored locally, that is, determines whether the historical request hash stored locally contains the same historical request hash as the current request hash. If it is determined to be contained, the cache record corresponding to the historical request hash that is the same as the current request hash is determined as the first cache record corresponding to the current request hash. After that, based on the cache position in the first cache record, the first network interface data is obtained, and the first network interface data is fed back to the business module that sends the first call request in the business layer. If it is determined that the historical request hashes stored locally do not contain the same historical request hash as the current request hash, it can be determined that the first network interface data does not exist in the local cache. Accordingly, the target program feeds back to the business layer (the business module that sends the first call request) an error message indicating that the first network interface data has not been obtained.

[0072] It is understandable that when the target program determines that it needs to obtain the first network interface data by reading the local cache, it can determine whether the corresponding cache data (i.e., the first network interface data) is contained in the local storage through the current request hash, that is, determine whether the first network interface data pre-requested by the network request corresponding to the current network request is stored locally. Specifically, based on the current request hash and each cache record corresponding to each historical request hash stored locally, determine whether the first cache record corresponding to the current request hash is stored locally, and the first cache record at least includes the cache location of the first network interface data; when it is determined that the first cache record is stored, the first network interface data is obtained based on the cache location in the first cache record. It is understandable that the "history" in the historical request hash only refers to the network request sent before the current network request, which is relative to the current network request and does not have other limiting meanings.

[0073] When the target program determines that it needs to obtain the first network interface data in the form of a network request, it can send the current network request corresponding to the current request hash to the server to request the first network interface data from the server, thereby obtaining the first network interface data.

[0074] Considering that when the network requests are exactly the same (i.e., the corresponding request hashes are the same) and the interval between sending network requests is short, the corresponding network interface data of the server may not have changed, that is, multiple identical network requests request the same network interface data from the server. If multiple identical network requests are sent to the server continuously within a short period of time, there will be a problem of multiple redundant requests to a certain extent, which will cause a waste of network resources, and the continuous sending of multiple identical network requests will increase the time consumption of network requests due to the occupation of bandwidth and server interfaces.

[0075] In view of the above situation, in one embodiment, the target program, in the process of sending the current network request corresponding to the current request hash, Figure 4 As shown, the following steps S410-S420 may be included: in step S410, based on the current request hash, determine whether the preset request dictionary contains a historical request hash that is the same as the current request hash, and the preset request dictionary records the historical request hashes of each historical network request that has been sent and for which the corresponding network interface data has not been received, and their corresponding request callback information.

[0076] In step S420, if it is determined that the preset request dictionary does not contain the same historical request hash as the current request hash, the current request hash and its corresponding request callback information are recorded in the preset request dictionary; and the current network request corresponding to the current request hash is sent.

[0077] In this implementation, the target program may pre-store a preset request dictionary. Each time the target program sends a network request, the request hash of the network request that has been sent and for which the corresponding network interface data has not been received, as well as the request callback information corresponding to the network request may be recorded in the preset request dictionary. The request callback information is information for calling back data to the business module (i.e., the interface caller) that sent the interface call request. Accordingly, the preset request dictionary records the historical request hashes of each historical network request that has been sent and for which the corresponding network interface data has not been received, and the corresponding request callback information.

[0078] If the target program determines that it needs to obtain the first network interface data in the form of a network request, it can first determine whether the preset request dictionary contains a historical request hash that is the same as the current request hash based on the current request hash. If it is determined that the preset request dictionary does not contain a historical request hash that is the same as the current request hash, it can be determined that there is currently no historical network request that is the same as the current network request, which has been sent and has not received the corresponding network interface data, that is, the target program has not sent a network request that is the same as the current network request to the server in a short period of time. Accordingly, the target program can record the current request hash and its corresponding request callback information in the preset request dictionary, and send the current network request to the server to obtain the corresponding network interface data (i.e., the first network interface data).

[0079] In another embodiment, during the aforementioned process of sending the current network request corresponding to the current request hash, the target program Figure 4 As shown, step S430 may also be included: in step S430, if it is determined that the preset request dictionary contains a historical request hash that is identical to the current request hash, the request callback information corresponding to the current request hash, corresponding to the historical request hash that is identical to the current request hash, is recorded in the preset request dictionary.

[0080] In this implementation, if it is determined that the preset request dictionary contains a historical request hash that is identical to the current request hash, it can be determined that the target program has sent a historical network request that is identical to the current network request (i.e., requesting the same network interface data) in a short period of time. In order to reduce redundant requests and avoid wasting network resources, the target program can record the request callback information corresponding to the current request hash, corresponding to the historical request hash that is identical to the current request hash, into the preset request dictionary, and then no longer send the current network request, but directly wait to receive the network interface data (i.e., the first network interface data) fed back by the server for the historical network request with the same historical request hash as the current request hash.

[0081] Then, in one embodiment, if Figure 4As shown, step S440 may also be included: in step S440, after obtaining the network interface data of the historical network request corresponding to the historical request hash identical to the current request hash, the historical request hash identical to the current request hash and several corresponding request callback information are deleted from the preset request dictionary.

[0082] After the target program obtains the network interface data of the historical network request corresponding to the historical request hash identical to the current request hash, it can determine that the historical network request corresponding to the historical request hash identical to the current request hash has been completed. Accordingly, the historical request hash identical to the current request hash and the corresponding request callback information can be deleted from the preset request dictionary to avoid the problem of missing the sending of network requests. In addition, after the target program obtains the network interface data (i.e., the first network interface data) of the historical network request corresponding to the historical request hash identical to the current request hash, it can call back the network interface data (i.e., the first network interface data) based on the request callback information corresponding to the historical request hash identical to the current request hash, that is, feed back the network interface data to each business module that needs the network interface data. Among them, each request callback information can indicate to whom (i.e., the business module) the network interface data is fed back.

[0083] In this implementation, multiple identical network requests within a short period of time can be issued only once, and the remaining network requests share the response data (i.e., network interface data) received by the network request that has been sent and has not received the corresponding network interface data, thereby reducing redundant requests, avoiding wasting network resources, and reducing the time consumption of network requests to a certain extent.

[0084] In this embodiment, the network request layer realizes unified management of network interface data through request hash, thereby improving data management efficiency. And considering the consistency judgment between the cached interface data and the network request, that is, the same network request (i.e., network request with the same request hash) hits the same network interface data, and different network requests (i.e., network requests with different request hashes) hit different network interface data, the network request layer can determine whether the network request to be initiated is the same based on the request hash, and then determine whether the network request to be initiated corresponds to the corresponding network interface (i.e., data), so as to avoid the isolation of the network interface data between the business models in the business layer to a certain extent, and realize the sharing of the locally cached network interface data between the business models in the business layer.

[0085] The sharing of network requests is realized at the network request layer. Each business module at the business layer can call the interface. The calling method is simple. It mainly determines whether the network requests are the same network requests based on the request hash determined by the network request configuration information. The judgment of the same network request does not depend on the business context, is non-invasive to the business, and has universality. And sharing can be completed based on conventional network requests.

[0086] It is understandable that in order to achieve better management of local cache data (i.e., cached network interface data), a maximum life cycle can be set for the local cache data (i.e., cached network interface data) so that the local cache data is valid at the period value of its corresponding maximum life cycle. In one embodiment, the first call request can also carry the period value of the maximum life cycle. When the period value is not 0, it can be determined that the corresponding network interface data needs to be cached locally. Accordingly, the method can also include:

[0087] After obtaining the first network interface data in the form of a network request, a cache record corresponding to the first network interface data is locally cached corresponding to the current request hash, wherein the cache record includes at least one of the following information: the cache location of the first network interface data, the cache time, the amount of cache space, the maximum life cycle set as a periodic value, and a result indicating whether the cached first network interface data has expired.

[0088] It can be understood that the cache record of the first network interface data can at least include the cache location (cachePlace), cache time (createTime) and maximum life cycle (maxAgeInSecond, whose unit can be seconds or other time units) of the first network interface data. Among them, the cache location records the actual storage location of the corresponding network interface data cached in the disk. The network interface data can be stored in a file, database or structured manner. The cache record can instruct the target program (or business module) to read the network interface data at the corresponding cache location. The cache time and the maximum life cycle set to the cycle value can jointly determine the validity period of the cached first network interface data. The cache space amount (i.e., the amount of space occupied by the network interface data, cost) can assist the network request layer in managing the network interface data cached locally. The result of identifying whether the cached first network interface data is expired can directly indicate whether the cached first network interface data has expired.

[0089] In one implementation, the cache record corresponding to the first network interface data may also include the most recent read time of the first network interface data (i.e., the last access or read time of the first network interface data), and the frequency of the first network interface data being read may be determined by the most recent read time, which may assist the network request layer in managing each network interface data cached locally. In one case, if the frequency of the first network interface data being read is determined to be high by the most recent read time (e.g., the time difference between the current read time and the most recent read time is less than a preset difference threshold), the first network interface data may also be stored in the memory of the electronic device where the target client is located, so as to increase the reading speed of the first network interface data.

[0090] Taking into account the limited local storage space of the electronic device where the target client is located, the target program provides a three-dimensional cache exit strategy (i.e., cache cleaning logic), and when the target client is running, the target program periodically checks and executes the cache cleaning logic. The first dimension is to clear the cached data based on the maximum life cycle corresponding to the cached network interface data; the second dimension is to clear the cached data based on the total amount of cache space occupied by the cached data; the third dimension is to clear the cached data based on the number of cache units (e.g., the number of cached data).

[0091] Specifically, in one embodiment, the target program determines that the first network interface data cached locally has expired based on the cache time and the maximum life cycle value in the cache record corresponding to the first network interface data, or based on the result of identifying whether the cached first network interface data has expired, and then deletes the first network interface data. It is understandable that when the target program determines that other cached network interface data has expired, it will also delete the other expired network interface data.

[0092] In another embodiment, the cache record corresponding to each cached network interface data may also include the most recent read time of the network interface data. Accordingly, the method may also include: when the target program determines that the total cache space of the local cache data exceeds the preset total space threshold, it deletes the network interface data with the earliest most recent read time or deletes the M network interface times with the earliest most recent read time. In this implementation, when the target program determines that the total cache space of the local cache data exceeds the preset total space threshold, it may determine that there are too many network interface data cached locally. In order to save data storage space, the network interface data with the earliest most recent read time or the M network interface times with the earliest most recent read time are deleted. Specifically, the target program may sort the cached network interface data according to their corresponding most recent read time (for example, in order from late to early, that is, the later the most recent read time, the higher the sorting position of the corresponding network interface data), delete the network interface data at the last position in the sorting order, or delete the network interface data at the last M positions in the sorting order.

[0093] In another embodiment, the cache record corresponding to each cached network interface data may also include the most recent read time of the network interface data. Accordingly, the method may also include: when the target program determines that the number of local cached data exceeds a preset number threshold, it deletes the network interface data with the earliest most recent read time or deletes the M network interface times with the earliest most recent read time. In this implementation, when the target program determines that the number of local cached data exceeds a preset number threshold, it may be determined that there is too much network interface data cached locally. In order to save data storage space, the network interface data with the earliest most recent read time or the M network interface times with the earliest most recent read time are deleted to save data storage space.

[0094] For network interface data stored both on the disk and in the memory, when deleting such data, it is necessary to delete such data from the disk and from the memory.

[0095] The foregoing describes certain embodiments of the present specification, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in an order different from that in the embodiments, and the desired results may still be achieved. In addition, the processes depicted in the accompanying drawings do not necessarily have to be performed in the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0096] Corresponding to the above method embodiment, this specification embodiment provides a data processing device 500, whose schematic block diagram is as follows: Figure 5 As shown, including:

[0097] The receiving module 510 is configured to receive a first call request for a first network interface from a business layer, wherein the first call request is used to indicate obtaining first network interface data required by the business layer, and the first call request carries at least current read cache policy information;

[0098] The acquisition module 520 is configured to acquire network request configuration information corresponding to the first call request;

[0099] A first determination module 530 is configured to determine a current request hash of a current network request to be initiated based on the network request configuration information;

[0100] The second determination module 540 is configured to obtain the first network interface data in a network request manner and / or in a local read cache manner based on the current request hash and the current read cache policy information, so as to feed back the first network interface data to the business layer.

[0101] In one possible implementation, the network request configuration information includes at least one of the following information: request link, request type, request serialization method, request object, response type, and environment variables.

[0102] In one possible implementation, the first determining module 530 is specifically configured to splice each information in the network request configuration information according to a preset information order to obtain spliced ​​information;

[0103] The splicing information is hashed using a preset hash algorithm to obtain the current request hash.

[0104] In one possible implementation, the current read cache policy information is one of the following policies:

[0105] Only obtain data through network requests, not by reading local cache;

[0106] Only obtain data by reading the local cache, not by making network requests;

[0107] First, obtain data through network request. If data acquisition fails, obtain data by reading local cache.

[0108] First, obtain data by reading the local cache. If data acquisition fails, obtain data through network request.

[0109] Data is obtained through network requests and reading local cache at the same time.

[0110] In one possible implementation, the first call request also carries a period value of a maximum life cycle;

[0111] The device also includes:

[0112] A storage module (not shown in the figure) is configured to locally store a cache record corresponding to the first network interface data corresponding to the current request hash after obtaining the first network interface data in the form of a network request, wherein the cache record includes at least one of the following information: the cache location of the first network interface data, the cache time, the amount of cache space, the maximum life cycle set to the period value, and a result indicating whether the cached first network interface data has expired.

[0113] In one possible implementation, it also includes:

[0114] The first deleting module (not shown in the figure) is configured to delete the first network interface data when it is determined that the first network interface data cached locally has expired.

[0115] In one possible implementation, the cache record further includes the time when the first network interface data was last read, and also includes:

[0116] The second deletion module (not shown in the figure) is configured to delete the network interface data with the earliest last read time or delete the M network interface times with the earliest last read time when it is determined that the total cache space of the local cache data exceeds a preset total space threshold.

[0117] In one possible implementation, the cache record further includes the time when the first network interface data was last read, and also includes:

[0118] The third deletion module (not shown in the figure) is configured to delete the network interface data with the earliest last read time or delete the M network interface times with the earliest last read time when it is determined that the number of local cached data exceeds a preset threshold.

[0119] In one possible implementation, the second determination module 540 is specifically configured to determine whether a first cache record corresponding to the current request hash is stored locally based on the current request hash and each cache record corresponding to each locally stored historical request hash, if it is determined that the first network interface data needs to be obtained by reading the local cache, wherein the first cache record at least includes a cache location of the first network interface data;

[0120] After determining that the first cache record is stored, the first network interface data is acquired based on a cache position in the first cache record.

[0121] In one possible implementation, the second determination module 540 is specifically configured to send a current network request corresponding to the current request hash to obtain the first network interface data if it is determined that the first network interface data needs to be obtained in the form of a network request.

[0122] In one possible implementation, the second determination module 540 is specifically configured to determine, based on the current request hash, whether a preset request dictionary contains a historical request hash that is the same as the current request hash, wherein the preset request dictionary records the historical request hashes of each historical network request that has been sent and for which corresponding network interface data has not been received and the corresponding request callback information;

[0123] If it is determined that the preset request dictionary does not contain the same historical request hash as the current request hash, the current request hash and its corresponding request callback information are recorded in the preset request dictionary; and the current network request corresponding to the current request hash is sent.

[0124] In one possible implementation, it also includes:

[0125] A recording module (not shown in the figure) is configured to record the request callback information corresponding to the current request hash, corresponding to the historical request hash identical to the current request hash, into the preset request dictionary if it is determined that the preset request dictionary contains a historical request hash identical to the current request hash.

[0126] In one possible implementation, it also includes:

[0127] The fourth deletion module (not shown in the figure) is configured to delete the historical request hash identical to the current request hash and its corresponding request callback information from the preset request dictionary after obtaining the network interface data of the historical network request corresponding to the historical request hash identical to the current request hash.

[0128] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.

[0129] Reference below Figure 6 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing the embodiments of this specification. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of this specification.

[0130] like Figure 6As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0131] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0132] In particular, according to an embodiment of the present specification, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present specification includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present specification are executed.

[0133] The embodiments of the present specification also provide a computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the data processing method provided in the present specification.

[0134] It should be noted that the computer-readable medium described in the embodiments of this specification may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of this specification, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the embodiments of this specification, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0135] The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist independently without being assembled into the electronic device. The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: receives a first call request for a first network interface from a business layer, wherein the first call request is used to indicate obtaining the first network interface data required by the business layer, and the first call request carries at least the current read cache policy information; obtains the network request configuration information corresponding to the first call request; based on the network request configuration information, determines the current request hash of the current network request to be initiated; based on the current request hash and the current read cache policy information, obtains the first network interface data in a network request manner and / or in a local read cache manner, so as to feed back the first network interface data to the business layer.

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

[0137] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the storage medium and computing device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0138] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present invention may be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.

[0139] The specific implementation methods described above further describe the purpose, technical solutions and beneficial effects of the embodiments of the present invention in detail. It should be understood that the above description is only a specific implementation method of the embodiments of the present invention and is not intended to limit the scope of protection of the present invention. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solution of the present invention shall be included in the scope of protection of the present invention.

Claims

1. A data processing method, comprising: Receiving a first call request for a first network interface from a service layer, wherein the first call request is used to instruct to obtain first network interface data required by the service layer, and the first call request carries at least current read cache policy information; Obtaining network request configuration information corresponding to the first call request, wherein the network request configuration information is configuration information of a network request layer relative to a current network request to be initiated by the first call request; Based on the network request configuration information, determine a current request hash of a current network request to be initiated; Based on the current request hash and the current read cache policy information, the first network interface data is obtained in a network request manner and / or in a local read cache manner, so as to feed back the first network interface data to the service layer, wherein the obtaining of the first network interface data in a network request manner and / or in a local read cache manner includes: If it is determined that the first network interface data needs to be obtained in the form of a network request, a current network request corresponding to the current request hash is sent to obtain the first network interface data; wherein the sending of the current network request corresponding to the current request hash includes: According to the current request hash, determining whether a preset request dictionary contains a historical request hash that is the same as the current request hash, the preset request dictionary recording the historical request hashes of each historical network request that has been sent and for which corresponding network interface data has not been received and the corresponding request callback information; If it is determined that the preset request dictionary does not contain the same historical request hash as the current request hash, the current request hash and its corresponding request callback information are recorded in the preset request dictionary; and the current network request corresponding to the current request hash is sent.

2. The method of claim 1, wherein: The network request configuration information includes at least one of the following information: request link, request type, request serialization method, request object, response type and environment variables.

3. The method of claim 1, wherein: Determining a current request hash of a current network request to be initiated includes: According to a preset information sequence, each information in the network request configuration information is spliced ​​to obtain spliced ​​information; The splicing information is hashed using a preset hash algorithm to obtain the current request hash.

4. The method of claim 1, wherein: The current read cache policy information is one of the following policies: Only obtain data through network requests, not by reading local cache; Only obtain data by reading the local cache, not by making network requests; First, obtain data through network request. If data acquisition fails, obtain data by reading local cache. First, obtain data by reading the local cache. If data acquisition fails, obtain data through network request. Data is obtained through network requests and reading local cache at the same time.

5. The method of claim 1, wherein: The first call request also carries a period value of the maximum life cycle; The method further comprises: After obtaining the first network interface data in the form of a network request, a cache record corresponding to the first network interface data is stored locally corresponding to the current request hash, wherein the cache record includes at least one of the following information: the cache location of the first network interface data, the cache time, the amount of cache space, the maximum life cycle set to the period value, and a result indicating whether the cached first network interface data has expired.

6. The method of claim 5, further comprising: When it is determined that the first network interface data cached locally has expired, the first network interface data is deleted.

7. The method according to claim 5, wherein the cache record further includes the last read time of the first network interface data, and the method further includes: When it is determined that the total amount of cache space of the local cache data exceeds the preset total amount of space threshold, the network interface data with the earliest most recent read time is deleted or the M network interface times with the earliest most recent read time are deleted.

8. The method according to claim 5, wherein the cache record further comprises the last read time of the first network interface data, and the method further comprises: When it is determined that the number of locally cached data exceeds a preset number threshold, the network interface data with the earliest most recent read time is deleted or the M network interface times with the earliest most recent read time are deleted.

9. The method of claim 1, wherein: The acquiring the first network interface data by means of a network request and / or by means of a local read cache includes: If it is determined that the first network interface data needs to be obtained by reading the local cache, based on the current request hash and the cache records corresponding to the historical request hashes stored locally, it is determined whether a first cache record corresponding to the current request hash is stored locally, where the first cache record at least includes a cache location of the first network interface data; After determining that the first cache record is stored, the first network interface data is acquired based on a cache position in the first cache record.

10. The method of claim 1, further comprising: If it is determined that the preset request dictionary contains the same historical request hash as the current request hash, the request callback information corresponding to the current request hash is recorded in the preset request dictionary corresponding to the same historical request hash as the current request hash.

11. The method of claim 10, further comprising: After obtaining the network interface data of the historical network request corresponding to the historical request hash identical to the current request hash, the historical request hash identical to the current request hash and several request callback information corresponding thereto are deleted from the preset request dictionary.

12. A data processing device, comprising: A receiving module, configured to receive a first call request for a first network interface from a business layer, wherein the first call request is used to indicate obtaining first network interface data required by the business layer, and the first call request carries at least current read cache policy information; An acquisition module configured to acquire network request configuration information corresponding to the first call request, wherein the network request configuration information is configuration information of a network request layer relative to a current network request to be initiated by the first call request; A first determination module is configured to determine a current request hash of a current network request to be initiated based on the network request configuration information; The second determination module is configured to obtain the first network interface data in a network request manner and / or in a local read cache manner based on the current request hash and the current read cache policy information, so as to feed back the first network interface data to the business layer, wherein the second determination module is specifically configured to send the current network request corresponding to the current request hash to obtain the first network interface data if it is determined that the first network interface data needs to be obtained in a network request manner; wherein, in the process of sending the current network request corresponding to the current request hash, it is included: according to the current request hash, determining whether the preset request dictionary contains the same historical request hash as the current request hash, the preset request dictionary records the historical request hashes and the corresponding request callback information of each historical network request that has been sent and has not received the corresponding network interface data; if it is determined that the preset request dictionary does not contain the same historical request hash as the current request hash, recording the current request hash and the corresponding request callback information in the preset request dictionary; and sending the current network request corresponding to the current request hash.

13. An electronic device comprising a memory and a processor, wherein: The memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 11 is implemented.

Citation Information

Patent Citations

  • Method and device for querying data

    CN111694869A