A gateway caching method, apparatus, device and storage medium
By generating cache configuration information on the server side and automatically determining the gateway cache data, the problem of low efficiency in manual configuration in existing technologies is solved, and efficient and flexible gateway cache management is achieved.
Patent Information
- Application Number
- CN202211112265.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-13
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-09-13
AI Technical Summary
In existing technologies, gateway caching requires manual pre-configuration of information, resulting in low efficiency and insufficient flexibility.
By generating cache configuration information on the server side, the system automatically determines the data that needs to be cached at the gateway, reducing manual intervention and improving configuration efficiency and flexibility.
It enables automatic configuration of the gateway cache by machines, improving configuration efficiency and flexibility, reducing manual intervention, and enhancing the response speed and flexibility of the gateway cache.
Smart Images

Figure CN115580532B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of computer application technology, and in particular to a gateway caching method, apparatus, device, and storage medium. Background Technology
[0002] Currently, in order to improve the response speed of the server, a gateway cache can often be set up on the server side to cache some data at the gateway for faster response.
[0003] However, the relevant technologies require manual pre-configuration of the gateway's settings to determine the data that needs to be cached on the gateway, which is inefficient and lacks flexibility in configuration. Summary of the Invention
[0004] To address the aforementioned problems, embodiments of this specification provide a gateway caching method, apparatus, device, and storage medium. The technical solution is shown below.
[0005] A gateway caching method, applied to a gateway, includes:
[0006] Obtain preset data from the server; the preset data includes cache configuration information, response information, and query information for the response information; the cache configuration information is generated by the server.
[0007] If it is determined that data needs to be cached based on the cache configuration information, the query information is added to the gateway configuration information, and the response information is stored in the gateway cache.
[0008] Optionally, the method for generating the cache configuration information includes:
[0009] The server generates cache configuration information that represents the data that needs to be cached based on the response information that meets the gateway caching conditions.
[0010] Optionally, obtaining preset data from the server includes:
[0011] Obtain the server's response data to the data query request; and / or
[0012] Retrieve the data to be cached as determined by the server.
[0013] Optionally, obtaining preset data from the server includes:
[0014] Obtain the server's response data to the data query request; the data query request is used to query and obtain the first data from the server.
[0015] The query information includes the first parameter used to determine the first data in the data query request, and / or the hash value of the first parameter; the response information includes the first data.
[0016] Optionally, the method further includes:
[0017] Obtain a data query request; the data query request is used to query and obtain first data from the server;
[0018] Based on the first parameter used to determine the first data in the data query request, generate matching information;
[0019] If it is determined that the gateway configuration information does not contain the information to be matched, the first data is retrieved from the server.
[0020] If it is determined that any query information in the gateway configuration information contains the information to be matched, and the gateway cache contains the response information corresponding to the query information, then in response to the data query request, the response information corresponding to the query information in the gateway cache is returned.
[0021] If it is determined that any query information in the gateway configuration information contains the information to be matched, and there is no response information corresponding to the query information in the gateway cache, the first data is retrieved from the server.
[0022] Optionally, the first parameter includes a Uniform Resource Locator (URL), a request method, and query parameters.
[0023] Optionally, adding the query information to the gateway configuration information includes:
[0024] For the query information, generate an information identifier for the query information;
[0025] Add the query information and the generated information identifier to the gateway configuration information.
[0026] Optionally, the method further includes:
[0027] Add the cache configuration information to the gateway configuration information;
[0028] A correspondence is established between the cache configuration information and the query information in the gateway configuration information, and the response information in the gateway cache.
[0029] Optionally, the cache configuration information includes at least one of the following: a cache identifier indicating whether data is cached, a cache update method, a cache validity period, and a cache strategy;
[0030] The step of storing the response information in the gateway cache includes:
[0031] Based on the cache configuration information, the response information is stored in the gateway cache.
[0032] Optionally, the cache configuration information includes: cache update method;
[0033] The method further includes:
[0034] When the cache update method included in the cache configuration information is asynchronous update, the corresponding response information is periodically queried from the server according to the query information in the gateway configuration information;
[0035] If the current response information being queried differs from the corresponding response information in the gateway cache, the corresponding response information in the gateway cache will be updated to the current response information being queried.
[0036] Optionally, the cache configuration information includes: cache update method;
[0037] The method further includes:
[0038] When the cache update method included in the cache configuration information is asynchronous update, the corresponding cache configuration information is periodically queried from the server according to the query information in the gateway configuration information;
[0039] If the current cache configuration information being queried differs from the corresponding cache configuration information in the gateway configuration information, the corresponding cache configuration information in the gateway configuration information will be updated to the current cache configuration information being queried.
[0040] Optionally, the cache configuration information includes: cache update method;
[0041] The method further includes:
[0042] If the cache update method included in the cache configuration information is asynchronous update, and the gateway cannot respond to at least one data query request that requires querying the response information, then a query update request for querying the response information is constructed and sent to the server, the current response information is obtained from the server, and the corresponding response information in the gateway cache is updated to the current response information being queried.
[0043] The current response information is used to respond to at least one data query request.
[0044] A gateway caching device, applied to a gateway, comprising:
[0045] The acquisition unit is used to acquire preset data from the server; the preset data includes cache configuration information, response information, and query information for the response information; the cache configuration information is generated by the server.
[0046] The caching unit is used to add the query information to the gateway configuration information and store the response information in the gateway cache when it is determined that data needs to be cached based on the cache configuration information.
[0047] Optionally, the method for generating the cache configuration information includes:
[0048] The server generates cache configuration information that represents the data that needs to be cached based on the response information that meets the gateway caching conditions.
[0049] Optionally, the acquisition unit is configured to: acquire the server's response data to the data query request; and / or acquire the data to be cached determined by the server.
[0050] Optionally, the acquisition unit is configured to:
[0051] Obtain the server's response data to the data query request; the data query request is used to query and obtain the first data from the server.
[0052] The query information includes the first parameter used to determine the first data in the data query request, and / or the hash value of the first parameter; the response information includes the first data.
[0053] Optionally, the device further includes a response unit for:
[0054] Obtain a data query request; the data query request is used to query and obtain first data from the server;
[0055] Based on the first parameter used to determine the first data in the data query request, generate matching information;
[0056] If it is determined that the gateway configuration information does not contain the information to be matched, the first data is retrieved from the server.
[0057] If it is determined that any query information in the gateway configuration information contains the information to be matched, and the gateway cache contains the response information corresponding to the query information, then in response to the data query request, the response information corresponding to the query information in the gateway cache is returned.
[0058] If it is determined that any query information in the gateway configuration information contains the information to be matched, and there is no response information corresponding to the query information in the gateway cache, the first data is retrieved from the server.
[0059] Optionally, the first parameter includes a Uniform Resource Locator (URL), a request method, and query parameters.
[0060] Optionally, the cache unit is used for:
[0061] For the query information, generate an information identifier for the query information;
[0062] Add the query information and the generated information identifier to the gateway configuration information.
[0063] Optionally, the cache unit is further configured to:
[0064] Add the cache configuration information to the gateway configuration information;
[0065] A correspondence is established between the cache configuration information and the query information in the gateway configuration information, and the response information in the gateway cache.
[0066] Optionally, the cache configuration information includes at least one of the following: a cache identifier indicating whether data is cached, a cache update method, a cache validity period, and a cache strategy;
[0067] The cache unit is used for:
[0068] Based on the cache configuration information, the response information is stored in the gateway cache.
[0069] Optionally, the cache configuration information includes: cache update method;
[0070] The cache unit is also used for:
[0071] When the cache update method included in the cache configuration information is asynchronous update, the corresponding response information is periodically queried from the server according to the query information in the gateway configuration information;
[0072] If the current response information being queried differs from the corresponding response information in the gateway cache, the corresponding response information in the gateway cache will be updated to the current response information being queried.
[0073] Optionally, the cache configuration information includes: cache update method;
[0074] The cache unit is also used for:
[0075] When the cache update method included in the cache configuration information is asynchronous update, the corresponding cache configuration information is periodically queried from the server according to the query information in the gateway configuration information;
[0076] If the current cache configuration information being queried differs from the corresponding cache configuration information in the gateway configuration information, the corresponding cache configuration information in the gateway configuration information will be updated to the current cache configuration information being queried.
[0077] Optionally, the cache configuration information includes: cache update method;
[0078] The cache unit is also used for:
[0079] If the cache update method included in the cache configuration information is asynchronous update, and the gateway cannot respond to at least one data query request that requires querying the response information, then a query update request for querying the response information is constructed and sent to the server, the current response information is obtained from the server, and the corresponding response information in the gateway cache is updated to the current response information being queried.
[0080] The current response information is used to respond to at least one data query request.
[0081] In the above technical solution, by adding cache configuration information generated by the server itself, the server can determine the data that needs to be cached at the gateway, thereby achieving automatic machine configuration, reducing manual intervention, improving configuration efficiency, and eliminating the need to pre-set configuration information in the gateway, thus increasing the flexibility of the settings. Attached Figure Description
[0082] To more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings.
[0083] Figure 1 This is a flowchart illustrating a gateway caching method provided in an embodiment of this specification;
[0084] Figure 2 This is a schematic diagram of the structure of a gateway caching device provided in the embodiments of this specification;
[0085] Figure 3 This is a schematic diagram of the structure of a device used to configure the methods of the embodiments of this specification. Detailed Implementation
[0086] To enable those skilled in the art to better understand the technical solutions in the embodiments of this specification, the technical solutions in the embodiments of this specification will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art should fall within the scope of disclosure.
[0087] Currently, in order to improve the response speed of the server, a gateway cache can often be set up on the server side to cache some data at the gateway for faster response.
[0088] However, the relevant technologies require manual pre-configuration of the gateway's settings to determine the data that needs to be cached on the gateway, which is inefficient and lacks flexibility in configuration.
[0089] To address the aforementioned technical problems, this specification provides a gateway caching method.
[0090] This method allows for the addition of cache configuration information for data that the server needs to cache at the gateway. The specific cache configuration information can be generated by the server itself, and the gateway can determine whether to perform gateway caching based on this configuration information.
[0091] Therefore, in this method, by adding cache configuration information generated by the server itself, the server can determine the data that needs to be cached at the gateway, thereby achieving automatic machine configuration, reducing manual intervention, and improving configuration efficiency.
[0092] Furthermore, since the server itself determines the data that needs to be cached at the gateway, the specific configuration rules can be defined by the server itself, without the need to pre-configure the information in the gateway, thereby increasing the flexibility of the settings.
[0093] The following section, with reference to the accompanying drawings, provides a detailed explanation of a gateway caching method provided in an embodiment of this specification.
[0094] like Figure 1 The diagram shown is a flowchart illustrating a gateway caching method provided in an embodiment of this specification.
[0095] Optionally, the entity executing this method flow can be a gateway.
[0096] This method may include the following steps.
[0097] S101: Obtain preset data from the server.
[0098] Optionally, the preset data may include cache configuration information, response information, and query information for the response information; the cache configuration information may be generated by the server.
[0099] S102: If it is determined that data needs to be cached based on the cache configuration information, add the query information to the gateway configuration information and store the response information in the gateway cache.
[0100] In this process, by adding cache configuration information generated by the server itself, the server can determine the data that needs to be cached at the gateway, thereby achieving automatic machine configuration, reducing manual intervention, improving configuration efficiency, and eliminating the need to pre-set configuration information in the gateway, thus increasing the flexibility of the settings.
[0101] Adding query information to the gateway configuration information facilitates subsequent queries of the gateway cache. Query information for finding response information can be found in the gateway configuration information, making it easy to determine whether the gateway cache includes the corresponding response information.
[0102] The following is a detailed explanation of each step.
[0103] 1. S101: Obtain the preset data from the server.
[0104] For the preset data, this method does not limit the specific form and content, as long as the data is obtained from the server.
[0105] Specifically, the preset data can be sent proactively by the server to the gateway, or it can be retrieved proactively by the gateway from the server. The preset data can also be the response data returned by the server in response to a request sent by the client, which is then forwarded by the gateway.
[0106] Optionally, the preset data may include cache configuration information, response information, and query information for the response information; the cache configuration information may be generated by the server.
[0107] Optionally, caching configuration information can be used to determine whether data needs to be cached in the gateway. This allows the server to determine the data that needs to be cached in the gateway based on the server-side caching configuration information, improving the efficiency of gateway caching and increasing the flexibility of gateway caching settings.
[0108] This embodiment does not limit the method and rules for the server to generate cache configuration information.
[0109] Optionally, the preset data can be a response message, and the cache configuration information can be a cache field added to the response message, specifically a cache field added to the message header, so as to determine whether data needs to be cached based on the value of the cache field.
[0110] Optionally, cache configuration information can be used to determine whether data needs to be cached. Specifically, cache configuration information may include a cache identifier that indicates whether data should be cached.
[0111] Therefore, the server can determine whether to cache the data at the gateway and then generate the corresponding cache configuration information.
[0112] This embodiment does not limit the criteria by which the server determines whether to cache data at the gateway.
[0113] Optionally, the method for generating cache configuration information may include: the server generating cache configuration information to characterize the data that needs to be cached based on the response information that meets the gateway caching conditions.
[0114] This embodiment does not limit the specific method of generating cache configuration information. Specifically, it can generate a cache identifier to represent the data that needs to be cached and add it to the cache configuration information corresponding to the response information; or it can generate cache configuration information with values within a valid range to represent the data that needs to be cached.
[0115] For example, in cases where data needs to be cached, a cache expiration period with a value greater than 0 can be generated as cache configuration information, so that the gateway can determine whether to cache based on the cache expiration period with a value greater than 0.
[0116] For cases where data does not need to be cached, you can either not generate cache configuration information directly, or generate a cache expiration period with a value less than 0 as cache configuration information, specifically -1, so that the gateway can determine that caching is not required based on a cache expiration period less than 0.
[0117] Alternatively, the server can generate the corresponding cache configuration information based on the manual configuration by business personnel or operations and maintenance personnel.
[0118] Optionally, in response to manual configuration by business or operations personnel on the development-side client (or the server's control terminal) coupled to the server, the server generates cached configuration information based on the results of the manual configuration.
[0119] For example, given a response message, if the server receives a result that is manually configured by the business personnel to indicate that it needs to be cached, it can generate cache configuration information to indicate that the data needs to be cached.
[0120] Optionally, the server may determine whether to cache data at the gateway based on factors such as the source of the response information, the type of request the response information responds to, the frequency, number of times, and popularity of the response information being accessed, the time the response information was generated, the data type of the response information, historical cache configuration information, and the update frequency of the response information.
[0121] Optionally, gateway caching conditions may include at least one of the following: the source of the response information is a preset source; the type of request responded to by the response information is a preset request type; the frequency of access to the response information is greater than the preset access frequency; the number of times the response information is accessed is greater than the preset number of accesses; the popularity of the response information is greater than the preset popularity; the generation time of the response information is within a preset time period; the type of the response information is a preset information type; the response information needs to be cached based on historical cache configuration information; the update frequency of the response information is lower than the preset update frequency, etc.
[0122] Optionally, when the gateway caching conditions meet at least one of the above, the server can automatically generate corresponding cache configuration information for the above response information; the server can also first send a cache prompt message to the development side client coupled to the server to prompt whether the business personnel of the development side client agree to the server generating corresponding cache configuration information for the above response information.
[0123] Once the business personnel have confirmed their agreement, the server can generate corresponding cache configuration information for the above response information.
[0124] Optionally, the server may include multiple application interfaces (APIs), specifically multiple application interface APIs for microservices. These APIs can respond to client requests and return response data. The server can be configured to generate response information for preset APIs and determine whether gateway caching is required.
[0125] In other words, gateway caching conditions can include: the source of the response information is a preset API. This allows for convenient gateway caching of response information from preset APIs, improving the data response capabilities of preset APIs and reducing the burden on preset APIs.
[0126] Optionally, for specific request types, the response information for that type of request can be cached on the gateway. Specific request types can be GET requests, requests with a data volume exceeding a preset data volume, requests with a priority higher than a preset priority, requests with a retrieval frequency higher than a preset retrieval frequency, etc. This embodiment does not limit the specific request type.
[0127] Optionally, the server can identify response information that is accessed more frequently than a preset access frequency as data that needs to be cached on the gateway, or it can identify response information that is accessed more times than a preset access number as data that needs to be cached on the gateway, or it can identify popular response information as data that needs to be cached on the gateway, or it can identify newly generated response information as data that needs to be cached on the gateway.
[0128] In this way, the probability of response information in the gateway cache being accessed can be increased, thereby improving the overall response efficiency of the server and reducing the server load.
[0129] Optionally, response information generated within a preset time period can be cached on the gateway, thereby simplifying the configuration process and improving configuration efficiency. This embodiment does not limit the specific preset time period; it can be from 11:00 AM to 5:00 PM daily, or a time period in which the server receives more requests than a preset request volume.
[0130] Optionally, response information of preset information types can also be cached on the gateway. Preset information types can specifically be information types with higher priority than a preset priority, or information types with a larger data volume than a preset data volume, etc.
[0131] Alternatively, the decision to cache data can be based on historical cache configuration information. Specifically, this can be based on the frequency or interval of cached data in the historical cache configuration information.
[0132] For example, the frequency of server-side data caching can be controlled within a preset frequency range. If the frequency exceeds the preset frequency range, subsequent response information can be skipped and the frequency can be directly reduced to the preset frequency range.
[0133] For example, the server can cache every 3 response messages on the gateway, so that if the first 3 response messages are not cached on the gateway, it can determine that the current response message needs to be cached on the gateway.
[0134] Optionally, for response information that is updated less frequently, which is usually more stable, gateway caching can be implemented to reduce the possibility of clients obtaining outdated response information.
[0135] Optionally, since the data cached in the gateway needs to be used for subsequent queries, the preset data may include response information and query information for the response information. Specifically, the response information may include information determined based on the query information, which can also include information determined on the server side based on the query information.
[0136] The response information query information can be used to retrieve response information from the server or from the gateway cache.
[0137] For example, query information may specifically include parameters used in the data query request to determine the data to be queried, while response information may specifically include the data retrieved on the server based on the query information.
[0138] This method does not limit the specific form and content of cache configuration information, query information, and response information.
[0139] In one alternative embodiment, the server can pre-send the data that needs to be cached at the gateway as preset data to the gateway for caching.
[0140] Alternatively, the server can respond to a data query request by forwarding the response data as preset data through the gateway. At the same time, the response data can be cached in the gateway for quick response using the cached response data in the future.
[0141] In this embodiment, the source of the data query request is not limited; it can be a client or other device.
[0142] Therefore, optionally, obtaining preset data from the server may include: obtaining the server's response data to the data query request; and / or obtaining data to be cached as determined by the server.
[0143] Optionally, obtaining preset data from the server may include: obtaining response data from the server in response to a data query request; the data query request may be used to query and obtain first data from the server.
[0144] Correspondingly, the query information may include the first parameter used to determine the first data in the data query request, and / or the hash value of the first parameter; the response information may include the first data. The first data is the data that the data query request actually needs to obtain.
[0145] The first parameter in the query information can be used to retrieve the first data from the server, which is the corresponding response information.
[0146] This method does not limit the specific form of the first parameter, as long as it can be used to determine the first data in the server.
[0147] Optionally, the first parameter may include a Uniform Resource Locator (URL), a request method, and query parameters.
[0148] In one optional embodiment, the gateway can receive data query requests. On the one hand, it can query whether there is response information in the gateway cache. On the other hand, when the server responds to the request, the gateway can forward the preset data of the response to determine whether it needs to be cached in the gateway.
[0149] Optionally, the above method flow may further include: obtaining a data query request; the data query request can be used to query and obtain first data from the server; and generating matching information based on the first parameter used to determine the first data in the data query request.
[0150] Optionally, the information to be matched can be used to match one or more query information in the gateway configuration information to determine whether the corresponding response information is cached in the current gateway.
[0151] This method does not limit the specific form and content of the information to be matched, as long as it can be used to match the query information in the gateway configuration information.
[0152] Optionally, the information to be matched can directly include the first parameter, or it can include the hash value of the first parameter. Specifically, the corresponding information to be matched can be generated based on the information format in the query information.
[0153] For example, the query information includes hash values generated for the request parameters.
[0154] Optionally, the gateway can query the gateway cache, which means that if it is determined that the gateway configuration information does not contain the information to be matched, the gateway can query the server to obtain the first data.
[0155] Optionally, the gateway configuration information may not include matching information; specifically, it may indicate that the gateway does not cache the response information required for a data query request. Therefore, the gateway can directly query the server to obtain the first data.
[0156] This embodiment does not limit the specific method by which the gateway queries and obtains the first data from the server. Optionally, the gateway can directly forward the data query request to the server, or the gateway can reconstruct a request for querying and obtaining the first data and send it to the server.
[0157] Optionally, for multiple data query requests that need to retrieve the first data, the gateway can construct a single request and send it to the server, eliminating the need to forward each data query request to the server, thus reducing the number of requests received by the server and improving the server's response efficiency.
[0158] Optionally, if it is determined that any query information in the gateway configuration information contains information to be matched, and the gateway cache contains response information corresponding to the query information, the response information corresponding to the query information in the gateway cache is returned in response to the data query request.
[0159] Optionally, if it is determined that any query information in the gateway configuration information contains information to be matched, and the gateway cache contains response information corresponding to the query information, the response information corresponding to the query information in the gateway cache can be returned in response to the data query request.
[0160] Optionally, if it is determined that any query information in the gateway configuration information contains information to be matched, and the gateway cache contains the corresponding response information, it can be determined that the gateway cache contains the response information required for the data query request, i.e., the first data. Therefore, the corresponding response information can be directly obtained from the gateway cache and returned. Specifically, the response information can be packaged and returned.
[0161] Optionally, if it is determined that any query information in the gateway configuration information contains information to be matched, and there is no response information corresponding to the query information in the gateway cache, the first data is retrieved from the server.
[0162] Optionally, if it is determined that any query information in the gateway configuration information contains information to be matched, and there is no response information corresponding to the query information in the gateway cache, the first data is retrieved from the server.
[0163] The gateway configuration information may contain invalid query information, or the gateway cache may have limited capacity, causing some data to be deleted as data increases. Therefore, even if it is determined that any query information in the gateway configuration information contains the information to be matched, the corresponding response information may not be obtained from the gateway cache, and the first data needs to be obtained from the server.
[0164] Optionally, preset data containing the first data can be retrieved from the server and used as a response message for the data query request.
[0165] Optionally, the preset data obtained from the server query may include first data, specifically, the preset data may include cache configuration information, response information, and query information of the response information.
[0166] The response information includes the first data, the query information includes the first parameter and / or the hash value of the first parameter; and the cache configuration information can be generated by the server and the gateway determines whether to cache the data.
[0167] 2. S102: If it is determined that data needs to be cached based on the cache configuration information, add the query information to the gateway configuration information and store the response information in the gateway cache.
[0168] This method does not limit the specific way of determining the data to be cached based on the cache configuration information.
[0169] Optionally, the cache configuration information may include a cache identifier. If the cache identifier is a first preset value, it can be determined that data needs to be cached. If the cache identifier is a second preset value, it can be determined that data does not need to be cached.
[0170] Alternatively, the determination can be made directly based on whether a valid value exists in the cache configuration information. If a valid value exists in the cache configuration information, it can be determined that data needs to be cached; if no valid value exists in the cache configuration information, it can be determined that data does not need to be cached.
[0171] For example, cache configuration information may include a cache expiration period, and the value of the cache expiration period is usually within a fixed range. Therefore, if the cache expiration period value in the cache configuration information is within a fixed range, it can be determined that data needs to be cached; conversely, if the cache expiration period value in the cache configuration information is within a fixed range, it can be determined that data does not need to be cached.
[0172] Specifically, if the cache expiration time is less than 0, it can be determined that no data needs to be cached. If the cache expiration time is greater than 0, it can be determined that data needs to be cached.
[0173] In one alternative embodiment, the query information can be added to the gateway configuration information to facilitate subsequent determination of whether the corresponding response information is stored in the gateway cache based on the query information.
[0174] Optionally, the query information may include a first parameter for determining the corresponding response information, which may specifically include a Uniform Resource Locator (URL), a request method, and query parameters.
[0175] Optionally, the request method may include GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE, and CONNECT methods, etc.
[0176] Optionally, to facilitate subsequent queries, a unique corresponding information identifier can be generated for the query information and added to the gateway configuration information. This allows the system to determine whether the query information exists in the gateway configuration information based on the information identifier, thereby improving query efficiency.
[0177] Of course, optionally, only the information identifier of the query information can be added to the gateway configuration information to save the storage resources of the gateway configuration information.
[0178] Therefore, optionally, adding query information to the gateway configuration information may include: generating an information identifier for the query information; and adding the query information and the generated information identifier to the gateway configuration information.
[0179] Optionally, adding query information to the gateway configuration information may include: generating an information identifier for the query information; and adding the generated information identifier to the gateway configuration information. Furthermore, a correspondence may be established between the information identifiers of the query information in the gateway configuration information and the response information in the gateway cache. Different query information may correspond to different information identifiers.
[0180] Alternatively, the information identifier of the query information can be added back to the query information as part of the query information.
[0181] Optionally, the information identifier for the query information can also be pre-generated and added to the gateway configuration information as part of the query information.
[0182] This embodiment does not limit the method for generating information identifiers for query information.
[0183] Optionally, a hash operation can be performed on the query information, and the result can be used as the information identifier.
[0184] Specifically, a hash operation can be performed on the first parameter in the query information, namely the Uniform Resource Locator (URL), the request method, and the query parameters, and the result can be used as the information identifier.
[0185] In an optional embodiment, when generating an information identifier for query information, generating matching information based on the first parameter used to determine the first data in the data query request can specifically include: generating an information identifier as matching information based on the first parameter used to determine the first data in the data query request.
[0186] The method for generating an information identifier for the first parameter of a data query request can be the same as the method for generating an information identifier for query information; specifically, both can utilize hash operations to generate the information identifier.
[0187] Optionally, the gateway configuration information does not contain information to be matched, which can indicate that the gateway configuration information does not contain the information identifier generated for the first parameter in the data query request.
[0188] Optionally, the gateway configuration information includes information to be matched, which can indicate that there is an information identifier in the gateway configuration information that contains query information. If this identifier is the same as the information identifier generated for the first parameter in the data query request, it can be determined that the first parameter in the data query request is the same as the first parameter in the query information. Then, the corresponding first data can be retrieved from the gateway cache.
[0189] For a detailed explanation, please refer to the text above.
[0190] In an optional embodiment, cache configuration information can be used to determine whether preset data needs to be cached.
[0191] In addition, the cache configuration information can optionally be used to determine how preset data should be cached.
[0192] Optionally, the specific settings can be based on the cache configuration information to determine the validity period of the preset data cache, the caching method, the cache location, the cache update method, and so on.
[0193] Optionally, the response information in the preset data can be cached according to the caching configuration information in the preset data. Specifically, the response information in the preset data can be stored in the gateway cache according to the cache validity period, caching strategy, caching method, cache location, etc. in the caching configuration information.
[0194] Optionally, to facilitate subsequent operations on cached response information, the cache configuration information in the preset data can also be added to the gateway configuration information.
[0195] For example, cached response information may need to be updated, and the cache update method in the cache configuration information can be added in advance to the gateway configuration information to facilitate subsequent cache updates.
[0196] Therefore, optionally, the above method flow may further include: adding cache configuration information to gateway configuration information; and constructing a correspondence between cache configuration information and query information in gateway configuration information and response information in gateway cache.
[0197] This method does not limit the specific form or construction method of the constructed correspondence.
[0198] Optionally, a mapping list can be set up, or the identifier of the response information can be added to the gateway configuration information and combined with the corresponding query information and cache configuration information into a single data entry. Specifically, the cache address of the response information can be added to the gateway configuration information and combined with the corresponding query information and cache configuration information into a single data entry, thereby facilitating the determination of the cache address of the corresponding response information based on the query information.
[0199] Similarly, for the cache configuration information and query information in the gateway configuration information, as well as the response information in the gateway cache, the cache configuration information and query information in the gateway configuration information, along with the corresponding response information identifier, can be combined into a single data entry. This makes it easier to determine the corresponding response information based on the query information. Specifically, the response information identifier can be the cache address of the response information.
[0200] Optionally, the cache configuration information may include at least one of the following: a cache identifier indicating whether data is cached, a cache update method, a cache validity period, and a cache policy; storing the response information in the gateway cache may include: storing the response information in the gateway cache according to the cache configuration information.
[0201] Optionally, the cache configuration information may include at least one of the following: a cache identifier indicating whether data is cached, a cache update method, a cache validity period, and a cache strategy.
[0202] Regarding the steps for generating cache configuration information on the server side, this embodiment does not limit the specific basis for the server to generate cache configuration information.
[0203] Optionally, the server can determine that the cache update method is asynchronous for frequently updated data; the server can set a fixed cache validity period, or set different cache validity periods for different data; the server can also set different caching strategies for different data. Specifically, for large amounts of data, the caching strategy can be set to store the data in a cache with slower read and write speeds in the gateway, or for small amounts of data, the caching strategy can be set to store the data in a cache with faster read and write speeds in the gateway.
[0204] In one alternative embodiment, the cache update method may include synchronous update and asynchronous update.
[0205] First, the response information cached in the gateway can be regarded as a copy of the same response information in the server, thus enabling fast response in the gateway cache.
[0206] However, the response information on the server side may change. For example, due to business adjustments or data updates, the actual response information on the server side may change. In this case, it is necessary to update the response information cached by the gateway to ensure consistency.
[0207] Optionally, the synchronous update can specifically be to directly synchronize the changed response information to the gateway cache whenever any response information on the server changes.
[0208] For example, regarding expired response information in the gateway cache, upon receiving a new data query request, the new data query request can be forwarded to the server. The server then retrieves the new response information and sends it to the gateway for forwarding. Subsequently, if the gateway determines that new response information needs to be cached, it can update the expired response information with the new response information, achieving synchronous updates.
[0209] For example, if a certain response information in the server changes, it can be directly synchronized and updated in the gateway cache.
[0210] Optionally, asynchronous updates can involve the gateway initiating an update request to check if the response information on the server has changed. If it has changed, an update can then be performed.
[0211] For example, when a gateway receives one or more new data query requests, it can initiate a query update request to retrieve the new response information from the server. Then, if the gateway determines that it needs to cache the new response information, it can update the invalid response information with the new response information, thus achieving asynchronous updates.
[0212] In addition to the possibility that the response message sent on the server may change, the cache configuration information corresponding to the response message may also change.
[0213] For example, if you need to keep the cache valid for a long time, you can continuously update the cache validity period in the cache configuration information; you may also need to update the cache strategy or the cache update method.
[0214] Therefore, the cache configuration information can also be updated through cache update.
[0215] The specific new cache configuration information can be generated by the server according to actual needs, and this embodiment is not limited to this. Please refer to the explanation above for details.
[0216] It should be noted that, when the cache update method is asynchronous, optionally, if the gateway cannot respond to one or more data query requests that need to query the same data in the server, it can construct a query update request to obtain the latest response data from the server and update the gateway cache to respond to the data query request.
[0217] Optionally, if the cache update method included in the cache configuration information is asynchronous update, and the gateway cannot respond to at least one data query request that requires querying response information, a query update request for querying response information is constructed and sent to the server. The current response information is obtained from the server, and the corresponding response information in the gateway cache is updated to the current response information being queried. The current response information can be used to respond to at least one data query request.
[0218] Optionally, a query update request for querying the response information can be constructed based on the query information in the response information. This embodiment does not limit the method of constructing the query update request.
[0219] This embodiment decouples the gateway's response to a data query request from the gateway's query for data on the server through asynchronous updates, which also reduces the number of requests received by the server and lowers the server load.
[0220] For example, multiple data query requests might simultaneously attempt to retrieve the same initial data. The gateway cache might not yet contain this initial data, or it might contain expired data, making a response impossible. By using asynchronous updates, the gateway can asynchronously initiate a single request to retrieve the initial data from the server. The gateway then returns the corresponding initial data for each query request, allowing the server to handle only the single asynchronous request from the gateway, reducing the number of requests and server load.
[0221] As for the asynchronous update cache update method, since the gateway itself constructs the query update request to perform the query update, it can further perform periodic query updates without other devices sending data query requests.
[0222] Therefore, the cache configuration information may optionally include: cache update method.
[0223] Optionally, if the cache update method included in the cache configuration information is asynchronous update, the current corresponding response information can be periodically queried from the server based on the query information in the gateway configuration information; if the current response information queried is different from the corresponding response information in the gateway cache, the corresponding response information in the gateway cache will be updated to the current response information queried.
[0224] Optionally, based on the query information in the gateway configuration information, a single query update request can be periodically constructed to query the corresponding response information from the server.
[0225] Optionally, if the cache update method included in the cache configuration information is asynchronous, the current corresponding cache configuration information is periodically queried from the server based on the query information in the gateway configuration information; if the current cache configuration information queried is different from the corresponding cache configuration information in the gateway configuration information, the cache configuration information corresponding to the gateway configuration information is updated to the current cache configuration information queried.
[0226] Optionally, based on the query information in the gateway configuration information, a single query update request can be periodically constructed to query the corresponding cache configuration information from the server.
[0227] This embodiment does not limit the specific duration of the asynchronous update cycle.
[0228] Specifically, in one optional example, one or more data entries whose cache update method is asynchronous can be determined from the gateway configuration information, thus enabling asynchronous updates.
[0229] A separate thread can be started in the gateway to handle asynchronous cache updates. The interval for asynchronous updates is not limited and can be set according to actual business needs; specifically, it can be 500ms.
[0230] Optionally, to better ensure the validity of cached response messages, the interval for setting asynchronous updates can be shorter than the cache validity period of the response messages.
[0231] For example, if the cache validity period for the response message is 10 seconds, the interval can be set to 3 seconds, so that asynchronous updates can be performed before the response message expires. Specifically, the cache validity period can be refreshed after each asynchronous update.
[0232] In this embodiment, asynchronous updates can improve the efficiency of gateway cache updates.
[0233] Thirdly, for gateways that have one or more cached response messages, a fast response can be provided for data query requests.
[0234] Therefore, optionally, the above method flow may further include: obtaining a data query request; the data query request is used to query and obtain first data from the server; generating matching information according to the first parameter used to determine the first data in the data query request; and, in the case that any query information in the gateway configuration information contains matching information and the gateway cache contains response information corresponding to the query information, responding to the data query request by returning the response information corresponding to the query information in the gateway cache.
[0235] Optionally, the above method flow may further include: obtaining a data query request; using the data query request to query and obtain first data from the server; generating matching information based on the first parameter used to determine the first data in the data query request; and querying and obtaining the first data from the server if it is determined that the gateway configuration information does not contain matching information.
[0236] If it is determined that any query information in the gateway configuration information contains information to be matched, and there is no corresponding response information in the gateway cache, the first data is retrieved from the server.
[0237] Optionally, the initial data can be retrieved from the server asynchronously. Specifically, this could involve asynchronously updating the cache.
[0238] Optionally, for multiple different data query requests used to retrieve the first data, the gateway can initiate a single data retrieval request to retrieve the first data from the server.
[0239] For example, multiple data query requests might simultaneously retrieve the same initial data. Specifically, there could be hundreds of such requests. Through asynchronous updates, the gateway can asynchronously initiate a single request to retrieve the initial data from the server and return the corresponding initial data for each query request.
[0240] This embodiment can use a gateway to asynchronously query and retrieve response data from the server for multiple requests, thereby reducing the number of requests received by the server, saving computing resources, and improving the server's response efficiency.
[0241] Optionally, after the gateway obtains the first data from the server, the gateway can further determine whether the first data needs to be cached, thereby facilitating a faster response later.
[0242] In addition, the gateway can also respond to data query requests and return the first data it has obtained.
[0243] For ease of understanding, this specification also provides a specific method embodiment.
[0244] The server side can include application interface APIs of multiple microservices. To enable the gateway to identify the data that needs to be cached, a cache field can be added to the header of the message returned by the application interface API.
[0245] The cache fields can specifically include cache expiration time, cache strategy, and cache update method.
[0246] The following explains the steps for parsing the messages returned by the server.
[0247] S201: Parse the response message sent by any application interface API.
[0248] S202: Based on the information in the response header, determine whether the data in the response message needs to be cached. Specifically, it can be determined whether there is a valid cache field in the response header.
[0249] S203: If a valid cache field exists, then based on the cache expiration and cache strategy in the cache field, a globally unique cache key will be generated according to the Uniform Resource Locator (URL), request method (method), and query parameter (query parameter) in the response message (a uniform hash algorithm can be used), and the response body data of the response message will be written to the cache (a cache updated based on the Least Recently Used algorithm can be used).
[0250] The URL can be used to determine the microservice API to be queried, and the request method can include GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE, and CONNECT.
[0251] The request method can usually be specified as the GET method.
[0252] S204: Update gateway configuration information. Specifically, you can add the generated cache key, cache fields, and the URL, method, and query parameters from the response message to the gateway configuration information.
[0253] S205: If no valid cached field exists, return the response message directly.
[0254] The following explains the steps for querying the gateway cache based on the received data query request.
[0255] S301: Parse data query request.
[0256] S302: Based on the first parameter in the data query request message, check whether the gateway configuration information contains the first parameter. Specifically, it can generate a cache key based on the url, method, and query param in the data query request message, and check whether the same cache key exists in the gateway configuration information.
[0257] S303: If the cache is not hit, the server is accessed directly; if the cache is hit, the corresponding packet body data in the gateway cache is packaged and returned.
[0258] In addition, for data that is updated asynchronously in the cache, the gateway can periodically query for updates from the corresponding microservice API on the server side.
[0259] Optionally, the gateway cache can be monitored to retrieve a list of microservice APIs corresponding to data requiring asynchronous updates from storage. The gateway then iterates through the API list to perform the queries and updates.
[0260] Specifically, the gateway can start a separate thread to handle asynchronous cache updates, performing an asynchronous cache update every 500ms (configurable).
[0261] Corresponding to the above method embodiments, this specification also provides an apparatus embodiment.
[0262] like Figure 2 The diagram shown is a schematic representation of a gateway caching device provided in an embodiment of this specification.
[0263] This device can be used in gateways.
[0264] The device may include the following units.
[0265] The acquisition unit 401 is used to acquire preset data from the server; the preset data includes cache configuration information, response information, and query information for the response information; the cache configuration information is generated by the server.
[0266] The caching unit 402 is used to add query information to the gateway configuration information and store response information in the gateway cache when it is determined that data needs to be cached based on the cache configuration information.
[0267] Optionally, the method for generating cache configuration information includes:
[0268] The server generates cache configuration information that represents the data that needs to be cached based on the response information that meets the gateway caching conditions.
[0269] Optionally, the acquisition unit 401 is used to: acquire the response data of the server to the data query request; and / or acquire the data to be cached determined by the server.
[0270] Optionally, the acquisition unit 401 is used for:
[0271] Retrieve the server's response to the data query request; the data query request is used to retrieve the first data from the server.
[0272] The query information includes the first parameter used to determine the first data in the data query request, and / or the hash value of the first parameter; the response information includes the first data.
[0273] Optionally, the device further includes a response unit 403, for:
[0274] Get a data query request; the data query request is used to retrieve the first data from the server.
[0275] Based on the first parameter used to determine the first data in the data query request, generate matching information;
[0276] If it is determined that the gateway configuration information does not contain the information to be matched, the first data is retrieved from the server.
[0277] If it is determined that any query information in the gateway configuration information contains the information to be matched, and the corresponding response information exists in the gateway cache, then in response to the data query request, the corresponding response information in the gateway cache is returned.
[0278] If it is determined that any query information in the gateway configuration information contains information to be matched, and there is no corresponding response information in the gateway cache, the first data is retrieved from the server.
[0279] Optionally, the first parameter includes a Uniform Resource Locator (URL), a request method, and query parameters.
[0280] Optionally, cache unit 402 is used for:
[0281] Generate information identifiers for the query information;
[0282] Add the query information and the generated information identifier to the gateway configuration information.
[0283] Optionally, cache unit 402 is also used for:
[0284] Add cache configuration information to the gateway configuration information;
[0285] Establish a correspondence between the cache configuration information and query information in the gateway configuration information and the response information in the gateway cache.
[0286] Optionally, the cache configuration information includes at least one of the following: a cache identifier indicating whether data is cached, a cache update method, a cache expiration period, and a cache strategy;
[0287] Cache unit 402 is used for:
[0288] Based on the cache configuration information, the response information is stored in the gateway cache.
[0289] Optionally, the cache configuration information includes: cache update method;
[0290] Cache unit 402 is also used for:
[0291] If the cache update method in the cache configuration information is asynchronous, the corresponding response information is periodically queried from the server based on the query information in the gateway configuration information.
[0292] If the current response information obtained from the query differs from the corresponding response information in the gateway cache, the corresponding response information in the gateway cache will be updated to the current response information obtained from the query.
[0293] Optionally, the cache configuration information includes: cache update method;
[0294] Cache unit 402 is also used for:
[0295] If the cache update method in the cache configuration information is asynchronous, the corresponding cache configuration information is periodically queried from the server based on the query information in the gateway configuration information.
[0296] If the current cache configuration information queried differs from the corresponding cache configuration information in the gateway configuration information, the corresponding cache configuration information in the gateway configuration information will be updated to the current cache configuration information queried.
[0297] Optionally, the cache configuration information includes: cache update method;
[0298] Cache unit 402 is also used for:
[0299] If the cache update method in the cache configuration information is asynchronous, and the gateway cannot respond to at least one data query request that requires querying response information, then a query update request for querying response information is constructed and sent to the server. The current response information is obtained from the server, and the corresponding response information in the gateway cache is updated to the current response information being queried.
[0300] The current response information is used to respond to at least one data query request.
[0301] For a detailed explanation of the above device embodiments, please refer to the above method embodiments.
[0302] This specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement any of the above method embodiments.
[0303] This specification also provides a computer-readable storage medium, wherein when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to implement any of the above-described method embodiments.
[0304] This specification also provides a computer device, which includes at least a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a gateway caching method when executing the program.
[0305] Figure 3 This diagram illustrates a more specific hardware structure of a computer device provided in an embodiment of this specification. The device may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, memory 1020, input / output interface 1030, and communication interface 1040 are interconnected internally via the bus 1050.
[0306] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0307] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0308] The input / output interface 1030 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.
[0309] The communication interface 1040 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0310] Bus 1050 includes a pathway for transmitting information between various components of the device, such as processor 1010, memory 1020, input / output interface 1030, and communication interface 1040.
[0311] It should be noted that although the above-described device only shows the processor 1010, memory 1020, input / output interface 1030, communication interface 1040, and bus 1050, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.
[0312] This specification also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements a gateway caching method.
[0313] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0314] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that the embodiments of this specification can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions of the embodiments of this specification, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this specification.
[0315] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.
[0316] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. When implementing the embodiments of this specification, the functions of each module can be implemented in one or more software and / or hardware. Alternatively, some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0317] The above description is merely a specific implementation of the embodiments of this specification. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles of the embodiments of this specification, and these improvements and modifications should also be considered as protection of the embodiments of this specification.
Claims
1. A gateway caching method applied to a gateway, characterized in that, The method comprises: obtaining preset data of a service end; the preset data comprises cache configuration information, response information, and query information of the response information; the cache configuration information is generated by the service end, and the service end generates cache configuration information for indicating that data needs to be cached, for response information meeting gateway cache conditions; the cache configuration information is used to determine whether data needs to be cached in the gateway; in a case where it is determined according to the cache configuration information that data needs to be cached, the query information is added to gateway configuration information, and the response information is stored in a gateway cache.
2. The method of claim 1, wherein, The obtaining of the preset data of the service end comprises: obtaining response data of the service end for a data query request; and / or obtaining data to be cached determined by the service end.
3. The method of claim 1, wherein, The obtaining of the preset data of the service end comprises: obtaining response data of the service end for a data query request; the data query request is used to query first data from the service end; the query information comprises a first parameter used to determine the first data in the data query request, and / or a hash value of the first parameter; and the response information comprises the first data.
4. The method of claim 1, wherein, The method further comprises: obtaining a data query request; the data query request is used to query first data from the service end; generating to-be-matched information according to a first parameter used to determine the first data in the data query request; in a case where it is determined that the gateway configuration information does not contain the to-be-matched information, querying the first data from the service end; in a case where it is determined that any query information in the gateway configuration information contains the to-be-matched information, and the response information corresponding to the query information exists in the gateway cache, returning, in response to the data query request, the response information corresponding to the query information in the gateway cache; in a case where it is determined that any query information in the gateway configuration information contains the to-be-matched information, and the response information corresponding to the query information does not exist in the gateway cache, querying the first data from the service end.
5. The method according to claim 3 or 4, characterized in that, The first parameter comprises a uniform resource locator identifier, a request method, and a query parameter.
6. The method of claim 1, wherein, The adding of the query information to the gateway configuration information comprises: generating an information identifier of the query information for the query information; adding the query information and the generated information identifier to the gateway configuration information.
7. The method of claim 1, wherein, The method further comprises: adding the cache configuration information to the gateway configuration information; constructing a corresponding relationship for the cache configuration information and the query information in the gateway configuration information, and the response information in the gateway cache.
8. The method of claim 1, wherein, The cache configuration information comprises at least one of the following: a cache identifier indicating whether data is cached, a cache update mode, a cache validity period, and a cache strategy; The storing of the response information in the gateway cache comprises: storing the response information in the gateway cache according to the cache configuration information.
9. The method of claim 7, wherein, The cache configuration information comprises a cache update mode. The method further comprises: In a case where the cache updating mode included in the cache configuration information is asynchronous updating, the current corresponding response information is periodically queried from the service end according to the query information in the gateway configuration information; In a case where the queried current response information is different from the corresponding response information in the gateway cache, the corresponding response information in the gateway cache is updated as the queried current response information.
10. The method of claim 7, wherein, The cache configuration information includes a cache updating mode. The method further includes: In a case where the cache updating mode included in the cache configuration information is asynchronous updating, the current corresponding cache configuration information is periodically queried from the service end according to the query information in the gateway configuration information; In a case where the queried current cache configuration information is different from the corresponding cache configuration information in the gateway configuration information, the corresponding cache configuration information in the gateway configuration information is updated as the queried current cache configuration information.
11. The method of claim 7, wherein, The cache configuration information includes a cache updating mode. The method further includes: In a case where the cache updating mode included in the cache configuration information is asynchronous updating, if the gateway cannot respond to at least one data query request requiring the response information, a query updating request for querying the response information is constructed and sent to the service end, the current response information is obtained from the service end, and the corresponding response information in the gateway cache is updated as the queried current response information; The current response information is used to respond to the at least one data query request.
12. A gateway cache apparatus applied to a gateway, characterized in that, It includes: An obtaining unit is configured to obtain preset data of a service end; the preset data includes cache configuration information, response information, and query information of the response information; The cache configuration information is generated by the service end, and the service end generates cache configuration information for indicating that data needs to be cached, for response information meeting a gateway cache condition; the cache configuration information is used to determine whether data needs to be cached in the gateway; A caching unit is configured to, in a case where it is determined according to the cache configuration information that data needs to be cached, add the query information to gateway configuration information, and store the response information into a gateway cache.
13. The apparatus of claim 12, wherein, The obtaining unit is configured to: Obtain response data of the service end for a data query request; the data query request is used to query and obtain first data from the service end; The query information includes a first parameter used to determine the first data in the data query request, and / or a hash value of the first parameter; the response information includes the first data.
14. An electronic device, comprising: It includes: A processor; A memory for storing processor-executable instructions; The processor is configured to execute the instructions to implement the method in any one of claims 1 to 11.
15. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can implement the method in any one of claims 1 to 11.
Citation Information
Patent Citations
Request processing method and device
CN111698273A