Data update methods and apparatus, electronic devices and storage media
Patent Information
- Application Number
- CN202310004532.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-03
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2043-01-03
AI Technical Summary
但若延长缓存数据失效的时间,又无法保证缓存数据的实时性
[0010] The data update method provided in this application, in response to a query request for target data, determines whether cached data corresponding to the target data exists in the cache database. If the cached data corresponding to the target data does not exist in the cache database, it obtains the parameter combination corresponding to the target data. The parameter combination consists of retrieving the cached data corresponding to the target data from the cache database and the index for retrieving the target data from the database. The parameter combination and the target cache query time are added to a parameter combination list. The target cache query time is the query time for the target data. The parameter combination list includes multiple parameter combinations and multiple cache query times. Based on the multiple cache query times, the cached data corresponding to each of the multiple parameter combinations is updated. By adding the parameter combination and the target cache query time to the parameter combination list, and updating the cached data based on the cache query time, a two-level update of the parameter combination list and the cached data in the cache database is achieved. This avoids repeated updates to the cached data, reduces the workload during caching, improves the real-time performance and timeliness of the cached data, reduces the possibility of frequently used cached data becoming invalid, and enhances the user's query experience.
Smart Images

Figure CN116126876B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a data update method and apparatus, electronic device and storage medium. Background Technology
[0002] With the increasing information technology of the times, the amount of data that needs to be stored is also increasing. In order to facilitate users' quick access to data, a caching system is generally used to solve this problem.
[0003] When a user needs to query data from a database, a caching system typically stores that data as cached data in a cache repository to reduce query time for subsequent queries. However, cached data in related technologies generally has an expiration time. When the cached data reaches its expiration time, it becomes invalid. Even after the cached data expires, when the user queries the data again, the data still needs to be retrieved from the database. Extending the expiration time, however, compromises the real-time performance of the cached data. Therefore, how to update cached data to ensure its real-time performance is a pressing issue that needs to be addressed. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this application provide a data update method and apparatus, an electronic device, and a storage medium to ensure the real-time performance of cached data.
[0005] In a first aspect, one embodiment of this application provides a data update method, the method comprising:
[0006] In response to a query request for target data, determine whether cached data corresponding to the target data exists in the cache database. If the cached data does not exist, obtain the parameter combination corresponding to the target data. The parameter combination consists of retrieving the cached data corresponding to the target data from the cache database and the index for retrieving the target data from the database. Add the parameter combination and the target cache query time to the parameter combination list. The target cache query time is the query time for the target data. The parameter combination list includes multiple parameter combinations and multiple cache query times. Based on the multiple cache query times, update the cached data corresponding to each of the multiple parameter combinations.
[0007] Secondly, one embodiment of this application provides a data updating apparatus, which includes: a determining module, configured to determine whether cached data corresponding to the target data exists in a cache database in response to a query request for target data; an obtaining module, configured to obtain a parameter combination corresponding to the target data if the cached data corresponding to the target data does not exist in the cache database, wherein the parameter combination is the cached data corresponding to the target data retrieved from the cache database and the index for retrieving the target data from the database; an adding module, configured to add the parameter combination and the target cache query time to a parameter combination list, wherein the target cache query time is the query time for the target data, and the parameter combination list includes multiple parameter combinations and multiple cache query times; and an updating module, configured to update the cached data corresponding to each of the multiple parameter combinations based on the multiple cache query times.
[0008] Thirdly, one embodiment of this application provides an electronic device, the electronic device comprising: a processor; a memory for storing processor-executable instructions; the processor being configured to perform the method described in the first aspect.
[0009] Fourthly, one embodiment of this application provides a computer-readable storage medium storing a computer program for performing the method described in the first aspect.
[0010] The data update method provided in this application, in response to a query request for target data, determines whether cached data corresponding to the target data exists in the cache database. If the cached data corresponding to the target data does not exist in the cache database, it obtains the parameter combination corresponding to the target data. The parameter combination consists of retrieving the cached data corresponding to the target data from the cache database and the index for retrieving the target data from the database. The parameter combination and the target cache query time are added to a parameter combination list. The target cache query time is the query time for the target data. The parameter combination list includes multiple parameter combinations and multiple cache query times. Based on the multiple cache query times, the cached data corresponding to each of the multiple parameter combinations is updated. By adding the parameter combination and the target cache query time to the parameter combination list, and updating the cached data based on the cache query time, a two-level update of the parameter combination list and the cached data in the cache database is achieved. This avoids repeated updates to the cached data, reduces the workload during caching, improves the real-time performance and timeliness of the cached data, reduces the possibility of frequently used cached data becoming invalid, and enhances the user's query experience. Attached Figure Description
[0011] The above and other objects, features, and advantages of this application will become more apparent from the more detailed description of the embodiments of this application in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the embodiments of this application to explain this application and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.
[0012] Figure 1 The diagram shown is a scenario applicable to an embodiment of this application.
[0013] Figure 2a The diagram shown is a flowchart illustrating a data update method provided in an exemplary embodiment of this application.
[0014] Figure 2b A schematic diagram of the cache database structure is shown.
[0015] Figure 3a The diagram shown is a flowchart illustrating a data query method provided in an exemplary embodiment of this application.
[0016] Figure 3b A flowchart illustrating the data query and update process is shown.
[0017] Figure 4 The diagram shown is a structural schematic of a data update device provided in an exemplary embodiment of this application.
[0018] Figure 5 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] The technical solution of this application embodiment is applied to a caching system, which is used to store data queried by users in a short period of time, so that users can quickly access the data.
[0021] When a user needs to query data from a database, the caching system typically stores that data as cached data in a cache library to reduce query time for subsequent queries. However, cached data in related technologies generally has an expiration time. When the cached data reaches its expiration time, it becomes invalid. Subsequent queries after cache expiration still require retrieving the data from the database. Due to the large volume of data in the database and the numerous underlying data points, this results in long response times and slow data loading, significantly impacting the user experience. However, extending the cache expiration time cannot guarantee the real-time performance of the cached data.
[0022] To ensure the real-time performance of cached data, the inventors have proposed the technical solution of this application after a series of studies. In the embodiments of this application, in response to a query request for target data, it is determined whether cached data corresponding to the target data exists in the cache database. If the cached data does not exist, a parameter combination corresponding to the target data is obtained. This parameter combination consists of retrieving the corresponding cached data from the cache database and the index for retrieving the target data from the database. The parameter combination and the target cache query time are added to a parameter combination list. The target cache query time is the query time for the target data. The parameter combination list includes multiple parameter combinations and multiple cache query times. Based on the multiple cache query times, the cached data corresponding to each of the multiple parameter combinations is updated. By adding the parameter combination and the target cache query time to the parameter combination list, and updating the cached data based on the cache query time, a two-layer update of the parameter combination list and the cached data in the cache database is achieved. This avoids repeated updates to the cached data, reduces the workload during caching, improves the real-time performance and timeliness of the cached data, reduces the possibility of frequently used cached data becoming invalid, and enhances the user's query experience.
[0023] Figure 1 The diagram illustrates a scenario applicable to an embodiment of this application. This scenario may include a data query front-end 101 and a data query device 102, wherein the data query device 102 includes a data update device 103.
[0024] For example, the data query front-end 101 can be a webpage, an APP (Application), or a mini-program, etc., and is not limited here. The data query device 102 is used to query the target data needed by the user. The data update device 103 is used to update the cached data corresponding to the target data. The specific update method will be described in detail in the following embodiments, and will not be repeated here.
[0025] In practical applications, taking a webpage as an example, the data query front-end 101 can be used by users to query target data by clicking the query control on the webpage. After the user clicks the target data to query, the data query device 102 will first check the cache database to see if there is cached data corresponding to the target data. If there is cached data corresponding to the target data, it will directly retrieve the cached data corresponding to the target data from the cache database and provide feedback to the user through the page. If there is no cached data corresponding to the target data, the data update device 103 will retrieve the target data from the database and update the cached data corresponding to the target data. After the cached data corresponding to the target data is updated, the data query device 102 will provide feedback to the user through the page.
[0026] Figure 2a The diagram shown is a flowchart illustrating a data update method provided in an exemplary embodiment of this application. Exemplarily. As... Figure 2a As shown in the embodiments of this application, the data update method includes the following steps.
[0027] Step S201: In response to a query request for the target data, determine whether cached data corresponding to the target data exists in the cache database.
[0028] For example, the target data can be the data that a user queries on a webpage according to their needs. The cache database is used to store the target data retrieved from the database. Once the target data is stored in the cache database, it becomes the cache data corresponding to the target data.
[0029] For example, if the target data is retrieved from the database and stored in the cache database, and the target data has not expired in the cache database, then it can be assumed that the cache database contains cached data corresponding to the target data.
[0030] For example, in actual application, if the judgment result of step S201 is yes, that is, there is cached data corresponding to the target data in the cache database, then step S202 is executed; if the judgment result of step S201 is no, that is, there is no cached data corresponding to the target data in the cache database, then step S203 is executed.
[0031] Step S202: Retrieve the cached data corresponding to the target data from the cache database and provide feedback.
[0032] Since the cached data corresponding to the target data exists in the cache database, the cached data can be retrieved directly from the cache database and fed back to the user who queries the target data, saving the time of downloading the target data from the database and improving the efficiency of the user's query for the target data.
[0033] Step S203: Obtain the parameter combination corresponding to the target data.
[0034] For example, the parameter combination is to retrieve the cached data corresponding to the target data from the cache database and the index of the target data from the database.
[0035] For example, the parameter combination consists of multiple business data, such as bizParam.method (routing method) and one or more of media, bizDate, bizHour, biz.current (current page number), biz.size (number of items per page), bizParam.orderField (sorting field), and bizParam.orderType (sorting type). There is no specific limitation here. The business data can show some information related to the target data. For example, if the target data is queried on page 1, the current time is 9:00 AM on January 1, 2022, and the routing method corresponding to the headline page on that day is method1, then the parameter combination will be page 1-2022-01-01-09:00-method1.
[0036] Step S204: Add the parameter combination and target cache query time to the parameter combination list.
[0037] For example, the target cache query time is the query time for the target data, and the parameter combination list includes multiple parameter combinations and multiple cache query times. Both the parameter combination list and the cache data are contained in the cache database.
[0038] For ease of understanding, Figure 2b A schematic diagram of the cache database structure is shown. It should be noted that... Figure 2b The example given is a parameter combination list with three parameter combinations. In reality, the number of parameter combinations in the parameter combination list is determined by the storage limit of the cache database.
[0039] like Figure 2b As shown, the cache database includes a list of parameter combinations and cached data. In the parameter combination list, "Media 1-Date 1-Hour 1-Route Method 1," "Media 2-Date 2-Hour 2-Route Method 2," and "Media 3-Date 3-Hour 3-Route Method 3" represent parameter combinations, while "Cache Query Time 1," "Cache Query Time 2," and "Cache Query Time 3" represent the cache query times corresponding to the above three parameter combinations, respectively. In the cached data, "Cache Data 1," "Cache Data 2," and "Cache Data 3" correspond to the above three parameter combinations through "Route Method 1," "Route Method 2," and "Route Method 3," respectively.
[0040] In practical applications, for example, if the parameter combination corresponding to the target data queried by a user is Media1-Date1-Hour1-RouteMethod1, then the cache query time 1 corresponding to this parameter combination will be updated to the time when the user queried the target data. Furthermore, using RouteMethod1 in this parameter combination, the corresponding cached data 1 will be found among multiple cached data sets and returned to the user. For example, if the parameter combination corresponding to the target data queried by a user is Media4-Date4-Hour4-RouteMethod4 (not shown in the diagram), but this parameter combination does not exist in the parameter combination list, then this parameter combination will be added to the parameter combination list, and the corresponding target cache query time will also be added to the parameter combination list (i.e., cache query time 4 will be added to the parameter combination list). Finally, the corresponding target data will be retrieved from the database, stored in the cache database, and returned to the user.
[0041] In practical applications, only target data corresponding to parameter combinations that exist in the parameter combination list will be stored as cached data in the cache database and participate in cache data updates to improve the query efficiency of target data. Therefore, it can be assumed that target data corresponding to parameter combinations not present in the parameter combination list does not exist in the cache. In this case, the parameter combination list will be updated based on the parameter combination corresponding to the target data queried by the user and the target cache query time for that target data, that is, the parameter combination and the corresponding target cache query time will be added to the parameter combination list. Of course, there are also cases where a parameter combination is removed from the parameter combination list due to an update, but the corresponding cached data is still in the cache database and has not expired. In this case, the parameter combination list will still be updated based on the parameter combination corresponding to the target data queried by the user and the target cache query time for that target data to extend the expiration time of the cached data.
[0042] Step S205: Update the cache data corresponding to each of the multiple parameter combinations based on multiple cache query times.
[0043] For example, each parameter combination in the parameter combination list has its own corresponding cache query time. Multiple cache query times can represent the target data that the user recently queried, or the target data that the user frequently uses.
[0044] Specifically, updating the cached data corresponding to multiple parameter combinations based on multiple cache query times can include the following steps.
[0045] Step A: Determine the M first parameter combinations that are closest to the target cache query time among multiple cache query times.
[0046] For example, the target cache query time can be considered as the time of the target data most recently queried by the user. The target data corresponding to the M first parameter combinations that are most recent to the target cache query time among multiple cache query times can be considered as the M target data that the user has recently queried, or the M target data that the user uses most often. The number of M can be set according to the storage limit of the cache database.
[0047] As one implementation method, multiple parameter combinations can be sorted based on multiple cache query times to obtain a first sorting result of multiple parameter combinations; based on the first sorting result of multiple parameter combinations, the ranking of each of the multiple parameter combinations in the parameter combination list is determined; and the first parameter combination whose ranking satisfies the first preset ranking condition is determined.
[0048] For example, each parameter combination in the parameter combination list has a corresponding cache query time. When sorting the parameter combinations, the parameter combinations can be sorted from the most recent to the oldest based on multiple cache query times to obtain the first sorting result. The cached data corresponding to the parameter combinations at the top of the first sorting result can be considered as the data that the user has recently queried or that is frequently used.
[0049] For example, the first sorting result is the ranking of the parameter combinations corresponding to the cached query time in the parameter combination list. The first preset ranking condition can be the top M parameter combinations, i.e., the aforementioned M first parameter combinations, or the parameter combination's ranking can be the top specified percentage of all parameter combinations in the parameter list, such as the top 20%. It should be noted that, regardless of the form of the preset ranking condition, the final number of parameter combinations represents the storage limit of the cache database.
[0050] Step B: Update the cached data corresponding to each of the M combinations of first parameters.
[0051] By updating the cached data corresponding to frequently used target data, the efficiency of users querying target data is improved, thus enhancing the user experience.
[0052] Specifically, the parameter combination list can also include multiple cache update times, which correspond to multiple cache query times. The cache update time can represent the expiration time of cached data. The earlier the cache update time, the closer it is to the expiration time of the cached data. The expiration time of the cached data can be set to a specified time from the cache update time. The specified time can be preset according to the usability of the target data. The expiration time of the cached data corresponding to each parameter combination in the parameter combination list can be the same or different, depending on the preset time. There is no limitation here.
[0053] Users can also query target data in batches. In this case, the target cache query time for multiple target data is the same, or when different users query different cache data, the target cache query time for multiple target data may also be the same. Therefore, it may be impossible to retrieve the cache data corresponding to exactly M combinations of first parameters. Therefore, further updates are made to the cache data corresponding to the M combinations of first parameters, including the following steps.
[0054] Step B1: If there are N second parameter combinations with the same cache query time among the M first parameter combinations, then according to the cache update time of each of the N second parameter combinations, remove Q second parameter combinations from the M first parameter combinations.
[0055] For example, M, N, and Q are all positive integers, M≥N, N≥2, and Q≥1.
[0056] Specifically, among the M first parameter combinations and N second parameter combinations with the same cached query time, it's possible that all second parameter combinations have the same cached query time, or that some second parameter combinations correspond to one cached query time while others correspond to a different cached query time. The number of second parameter combinations with different cached query times depends on the specific situation and is not limited to two. If the cached query time is the same for all second parameter combinations, the Q second parameter combinations with the latest cached update time from the N second parameter combinations are selected and removed from the M first parameter combinations. The latest cached update time indicates that the cached data corresponding to that update time is furthest from expiration. If some second parameter combinations correspond to one cached query time while others correspond to a different cached query time, first determine the subset of second parameter combinations with the earliest cached query time within each subset. Then, select the Q second parameter combinations with the latest cached update time from the N second parameter combinations within that subset and remove them from the M first parameter combinations.
[0057] As one implementation method, the parameter combinations corresponding to multiple identical cache query times can be sorted according to the cache update times corresponding to multiple identical cache query times to obtain a second sorting result of multiple parameter combinations; based on the second sorting result, the ranking of each of the multiple parameter combinations is determined, and the parameter combinations whose rankings meet the first preset ranking conditions are determined; the parameter combinations whose rankings do not meet the first preset ranking conditions are removed from the parameter combination list.
[0058] For example, when the cache query times are the same, the parameter combinations with the same cache query times will be sorted in order of cache update time from most recent to oldest, resulting in a second sorting result for multiple parameter combinations. The second sorting result is a further sorting of parameter combinations with the same cache query times based on the cache update time, on the basis of the first sorting result.
[0059] When updating the cached data corresponding to parameter combinations, the system prioritizes updating frequently used cached data and prioritizes updating cached data that expires faster, thus improving the real-time performance of cached data. Furthermore, by removing parameter combinations that exceed the storage limit of the parameter combination list from the parameter combination list, the system reduces the burden on the cache database and avoids caching too much useless data in the cache database.
[0060] Step B2: Update the cache data corresponding to the remaining MQ first parameter combinations after removal.
[0061] Specifically, updating the cached data corresponding to the remaining MQ first parameter combinations after removal can include the following steps.
[0062] Step B 2-1 : Search the database for the target data corresponding to each of the MQ first parameter combinations.
[0063] For example, target data can be labeled in the database using routing method parameters. The name of the routing method parameter is the same as the name of the routing method parameter that makes up the parameter combination corresponding to the target data. The corresponding target data can be found in the database using the routing method parameter with the same name.
[0064] Step B 2-2 Using the target data, update the cached data corresponding to each of the first parameter combinations in the cache thread pool.
[0065] For example, a thread pool is a form of multi-threaded processing. In a cache thread pool, the cached data distribution corresponding to each combination of the first parameters of MQ can be updated simultaneously.
[0066] In this way, updating the cached data using the target data ensures the real-time nature of the cached data.
[0067] As one implementation, since updating the cached data corresponding to all parameter combinations in the parameter combination list every time puts a relatively large load on the cache thread pool, this method can also include: determining the cache update time corresponding to multiple parameter combinations; and updating the cached data corresponding to the parameter combinations whose cache update time meets the preset time condition among the multiple parameter combinations.
[0068] For example, the preset time condition is a threshold for the cache update time that parameter combinations can be updated. Taking a preset time condition of two minutes as an example, in the parameter combination list, the cache data corresponding to parameter combinations with a cache update time of less than two minutes can be updated.
[0069] When updating cached data corresponding to parameter combinations that meet preset time conditions, the cache update time of the cached data is refreshed, and the target data in the database is used to update the cached data, thus ensuring the real-time performance of the cached data.
[0070] By updating the cached data corresponding to parameter combinations that meet preset time conditions in the parameter list, the possibility of frequently used cached data becoming invalid is reduced, thus improving the user's query experience.
[0071] Since the target cache query time corresponding to the target data will change after the user queries the target data, the method may also include: updating the target cache query time corresponding to the target data if the target data exists in the cache database; and updating the cache data corresponding to multiple parameter combinations based on the updated target cache query time corresponding to the target data.
[0072] For example, when updating cached data corresponding to parameter combinations, updating the cached data based on the target cache query time corresponding to the updated target data can prioritize updating frequently used cached data, thereby improving the query efficiency of the target data.
[0073] To ensure the real-time nature of cached data, the method may further include: traversing the parameter combination list at preset time intervals to determine parameter combinations whose cache update time is within a preset time range; and updating the cached data corresponding to the parameter combinations whose cache update time is within the preset time range.
[0074] For example, the preset time interval is the time for periodically traversing the parameter combination list, such as one minute. Every minute, multiple parameter combinations in the parameter combination list are traversed to determine the parameter combinations whose cache update time is within the preset time range. The cached data corresponding to the parameter combinations whose cache update time is within the preset time range is then updated. The preset time range can represent the warning range for cached data that is about to expire. The cached data corresponding to the parameter combinations within the preset time range can be updated to improve the timeliness of the cached data. By periodically traversing the parameter combination list and updating the cached data that is about to expire, repeated updates to cached data with long expiration times are avoided, improving the timeliness of the cached data and enhancing the user experience.
[0075] In practical applications, users can query target data on a webpage. When a user queries the target data by clicking the query control on the webpage, multiple business parameters corresponding to the target data are invoked to form a parameter combination. Through the routing method parameter in the parameter combination, the mapping relationship between the parameter combination and the cached data in the cache database, the target data in the database, and the backend API interface corresponding to the webpage can be determined. Through this mapping relationship, when the user clicks the query control on the webpage, the parameter combination corresponding to the target data and the backend API interface corresponding to the webpage can be determined. A connection is established between the backend API interface and the parameter combination list, and the cached data is updated and retrieved through the data update method mentioned in the embodiments of this application. After retrieving the cached data corresponding to the target data, the cached data is returned to the corresponding webpage and presented to the user through the backend API interface.
[0076] In this embodiment of the application, by updating the parameter combination list in the cache database and the cache data in a two-level manner, the repeated updates of the cache data are avoided, the workload of caching is reduced, the real-time performance and timeliness of the cache data are improved, the possibility of frequently used cache data becoming invalid is reduced, and the user's query experience is enhanced.
[0077] Figure 3a The diagram shown is a flowchart illustrating a data query method provided in an exemplary embodiment of this application. Exemplarily. For example... Figure 3a As shown in the embodiments of this application, the data query method includes the following steps.
[0078] Step S301: In response to the user's query request for target data, determine the business data corresponding to the target data.
[0079] For example, users can send query requests by clicking the query control on the webpage, and each target data corresponds to multiple business data. These business data can include one or more of the following: bizParam.method (routing method), media, bizDate, bizHour, biz.current (current page number), biz.size (number of items per page), bizParam.orderField (sorting field), and bizParam.orderType (sorting type), without specific limitations here.
[0080] Step S302: Use business data to form the parameter combination corresponding to the target data.
[0081] For example, by connecting business data together, parameter combinations can be obtained.
[0082] Step S303: Determine whether cached data corresponding to the target data exists in the cache database.
[0083] For example, a cache database may include multiple sub-cache databases, each of which may store one cached data entry. Alternatively, a database may include multiple sub-databases, each of which may store one target data entry.
[0084] Specifically, the target data, the cached data corresponding to the target data, the sub-database storing the target data, and the sub-cached database storing the cached data corresponding to the target data can all be labeled with routing method parameters of the same name in advance. By using these routing method parameters, it can be quickly and accurately determined whether the cached data corresponding to the target data exists in the cache database. It can be assumed that if there is a sub-cached database in the cache database with a routing method parameter labeled with the same name as the target data, then the cached data corresponding to the target data exists in the cache database.
[0085] For example, in actual application, if the judgment result of step S303 is yes, that is, there is cached data corresponding to the target data, then step S304 is executed; if the judgment result of step S303 is no, that is, there is no cached data corresponding to the target data, then step S305 is executed.
[0086] Step S304: Return the cached data to the user.
[0087] For example, cached data is returned to the webpage where the user queries the target data.
[0088] Step S305: Find the target data corresponding to the parameter combination in the database, update it in the cache database, and return it to the user.
[0089] The target data is updated using the above-mentioned method. Figure 2a The method implementations mentioned in the embodiments will not be described again here.
[0090] For ease of understanding, Figure 3b A flowchart illustrating the data query and update process is shown.
[0091] like Figure 3bAs shown, in practical applications, after receiving a user's query request for target data, multiple business data corresponding to the target data are identified, and these business data are combined into parameter combinations corresponding to the target data. These business data include at least routing method parameters. Using these routing method parameters, the target data required by the user can be obtained. First, the routing method parameters need to be used to determine if cached data corresponding to the target data exists in the cache database. If the cached parameters for the target data exist in the cache database, the cached data corresponding to the target data can be directly returned to the user, and the parameter combination list is updated. If the cached parameters for the target data do not exist in the cache database, the corresponding target data is retrieved from the database using the routing method parameters, returned to the user, and the target data is updated in the cache database as cached data.
[0092] When no user request for target data is received, a scheduled task can be set to periodically traverse the parameter combination list. After traversing the parameter combination list, the cached data corresponding to the parameter combinations that meet the update conditions will be updated in the cache thread pool. The update condition can be that the expiration time of the cached data corresponding to the parameter combination reaches a time threshold, such as a time threshold of two minutes. If the expiration time of the cached data is within two minutes, the cached data corresponding to that parameter combination will be updated. The parameter combination list is initially preset based on the parameter combinations corresponding to the target data that the user may frequently use. After the user queries the target data, it is updated according to the target cache query time of the user's query for the target data and the cache update time of the cached data corresponding to the target data.
[0093] The above text combined Figure 2a The data update method embodiments of this application are described in detail below, in conjunction with... Figure 4 This application provides a detailed description of embodiments of the data update apparatus. It should be understood that the descriptions of the data update method embodiments correspond to the descriptions of the data update apparatus embodiments; therefore, any parts not described in detail can be found in the preceding method embodiments.
[0094] Figure 4 The diagram shown is a structural schematic of a data update device provided in an exemplary embodiment of this application. Figure 4 As shown in the embodiments of this application, a data update device may include the following modules.
[0095] The determination module 401 is used to determine whether cached data corresponding to the target data exists in the cache database in response to a query request for the target data.
[0096] The acquisition module 402 is used to acquire the parameter combination corresponding to the target data if the cache data corresponding to the target data does not exist in the cache database.
[0097] For example, the parameter combination is to retrieve the cached data corresponding to the target data from the cache database and the index of the target data from the database.
[0098] Add module 403 to add parameter combinations and target cache query time to the parameter combination list.
[0099] For example, the target cache query time is the query time for the target data, and the parameter combination list includes multiple parameter combinations and multiple cache query times;
[0100] The update module 404 is used to update the cached data corresponding to multiple parameter combinations based on multiple cache query times.
[0101] In one embodiment of this application, the update module 404 is further configured to determine the M first parameter combinations that are closest to the target cache query time among a plurality of cache query times; and update the cache data corresponding to the M first parameter combinations respectively.
[0102] In one embodiment of this application, the update module 404 is further configured to: if there are N second parameter combinations with the same cache query time among the M first parameter combinations, then according to the cache update time of each of the N second parameter combinations, remove Q second parameter combinations from the M first parameter combinations; update the cache data corresponding to the remaining MQ first parameter combinations after removal; wherein M, N, and Q are all positive integers, M≥N, N≥2, and Q≥1.
[0103] In one embodiment of this application, the data update device may further include the following modules.
[0104] The first determination module is used to determine the cache update time corresponding to each combination of multiple parameters.
[0105] The first update module is used to update the cached data corresponding to parameter combinations whose cache update time meets the preset time condition among multiple parameter combinations.
[0106] In one embodiment of this application, the update module 404 is further configured to: search for target data corresponding to each of the MQ first parameter combinations in the database; and update the cache data corresponding to each of the MQ first parameter combinations in the cache thread pool using the target data.
[0107] In one embodiment of this application, the data update device may further include the following modules.
[0108] The second update module is used to update the target cache query time corresponding to the target data if the cache database contains cache data corresponding to the target data.
[0109] The third update module is used to update the cache data corresponding to multiple parameter combinations based on the target cache query time corresponding to the updated target data.
[0110] In one embodiment of this application, the data update device may further include the following modules.
[0111] The second determining module is used to traverse the parameter combination list at preset time intervals to determine parameter combinations whose cache update time is within the preset time range.
[0112] The fourth update module is used to update the cached data corresponding to parameter combinations whose update time is within a preset time range.
[0113] It should be understood that Figure 4 The operation and functions of the determination module 401, acquisition module 402, addition module 403, and update module 404 in the provided data update device can be referred to the above. Figure 2a The provided data update methods will not be elaborated here to avoid repetition.
[0114] Below, for reference Figure 5 This describes an electronic device according to embodiments of the present application. Figure 5 The diagram shown is a structural schematic of an electronic device provided in an exemplary embodiment of this application.
[0115] like Figure 5 As shown, the electronic device 50 includes one or more processors 501 and memory 502.
[0116] The processor 501 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and may control other components in the electronic device 50 to perform desired functions.
[0117] The memory 502 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 501 may execute the program instructions to implement the methods of the various embodiments of this application described above and / or other desired functions. Various contents, such as parameter combinations and parameter combination lists, may also be stored in the computer-readable storage medium.
[0118] In one example, the electronic device 50 may also include an input device 503 and an output device 504, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0119] The input device 503 may include, for example, a keyboard, a mouse, etc.
[0120] The output device 504 can output various information to the outside, including parameter combinations, parameter combination lists, etc. The output device 504 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0121] Of course, for the sake of simplicity, Figure 5 Only some of the components of the electronic device 50 relevant to this application are shown in this illustration; components such as buses, input / output interfaces, etc., are omitted. In addition, the electronic device 50 may include any other suitable components depending on the specific application.
[0122] In addition to the methods and apparatus described above, embodiments of this application may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps of the methods according to the various embodiments of this application described above.
[0123] Computer program products can be written in any combination of one or more programming languages to perform the operations of the embodiments of this application. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0124] Furthermore, embodiments of this application may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the steps of the methods described above according to various embodiments of this application.
[0125] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0126] The basic principles of this application have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this application are merely examples and not limitations, and should not be considered as essential features of each embodiment of this application. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the application to the necessity of employing the aforementioned specific details for implementation.
[0127] The block diagrams of devices, apparatuses, devices, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0128] It should also be noted that in the apparatus, equipment, and methods of this application, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions of this application.
[0129] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this application. Therefore, this application is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0130] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this application to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. A data updating method characterized by comprising: include: In response to a query request for target data, determine whether cached data corresponding to the target data exists in the cache database; If the cached data corresponding to the target data does not exist in the cache database, then the parameter combination corresponding to the target data is obtained. The parameter combination is the cached data corresponding to the target data retrieved from the cache database and the index of the target data retrieved from the database. The parameter combination and the target cache query time are added to the parameter combination list. The target cache query time is the query time for the target data. The parameter combination list includes multiple parameter combinations, multiple cache query times, and multiple cache update times. The multiple cache update times and the multiple cache query times have a corresponding relationship. Determine the M first parameter combinations among the plurality of cache query times that are closest to the target cache query time; If there are N second parameter combinations with the same cache query time among the M first parameter combinations, then according to the cache update time of each of the N second parameter combinations, Q second parameter combinations among the N second parameter combinations are removed from the M first parameter combinations; Update the cached data corresponding to the remaining MQ first parameter combinations after removal; wherein M, N, Q are all positive integers, M N, N 2, Q 1.
2. The method of claim 1, wherein, The parameter combination list also includes multiple cache update times, and these multiple cache update times have a corresponding relationship with the multiple cache query times; The method further includes: Determine the cache update time corresponding to each of the multiple parameter combinations; The cache data corresponding to the parameter combination whose cache update time meets the preset time condition among the multiple parameter combinations is updated.
3. The method of claim 1, wherein, The step of updating the cached data corresponding to the remaining MQ first parameter combinations after removal includes: Search the database for the target data corresponding to each of the MQ first parameter combinations; Using the target data, the cached data corresponding to the first parameter combinations of MQ are updated in the cache thread pool.
4. The method of claim 1, wherein, The method further includes: If cached data corresponding to the target data exists in the cache database, then update the target cache query time corresponding to the target data; Based on the target cache query time corresponding to the updated target data, the cache data corresponding to the multiple parameter combinations is updated.
5. The method according to claim 1, characterized in that, The method further includes: The parameter combination list is traversed according to a preset time interval to determine the parameter combination whose cache update time is within the preset time range; The cache update time is used to update the cache data corresponding to the parameter combination within the preset time range.
6. A data update device, characterized in that, include: The determination module is used to determine whether cached data corresponding to the target data exists in the cache database in response to a query request for the target data; The acquisition module is used to acquire a parameter combination corresponding to the target data if the cache data corresponding to the target data does not exist in the cache database. The parameter combination is the cache data corresponding to the target data retrieved from the cache database and the index for retrieving the target data from the database. An add module is used to add the parameter combination and the target cache query time to the parameter combination list. The target cache query time is the query time for the target data. The parameter combination list includes multiple parameter combinations, multiple cache query times, and multiple cache update times. The multiple cache update times and the multiple cache query times have a corresponding relationship. The update module is used to determine the M combinations of first parameters that are closest to the target cache query time among the plurality of cache query times; If there are N second parameter combinations with the same cache query time among the M first parameter combinations, then according to the cache update time of each of the N second parameter combinations, Q second parameter combinations among the N second parameter combinations are removed from the M first parameter combinations; Update the cached data corresponding to the remaining MQ first parameter combinations after removal; Where M, N, and Q are all positive integers, M N, N 2, Q 1.
7. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the data update method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program for executing the data update method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Data caching method and device, data querying method and device, lazy caching system and storage medium
CN111767314A