Data caching method and device, equipment and medium
By adjusting the cache generation frequency, the problem of the impact of active caching on local, third-party and databases is solved, and the stability of data caching and the overall stability of the system are achieved.
Patent Information
- Application Number
- CN202410711527.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-08-30
AI Technical Summary
Active caching affects the normal operation of local, third-party and databases in data services, mainly because high-frequency data access leads to a surge in resource consumption and requests, affecting system stability.
By obtaining the preset frequency adjustment parameters and cache parameters, determine the cache generation coefficient, and adjust the cache generation frequency based on target data such as local resource idle rate, external response time and database data to control the generation speed of the data cache and ensure that the cache frequency is appropriate Within the scope, adapt to the current situation and reduce the impact on the system.
It effectively reduces the impact of data caching on local, third-party and databases, improves the stability of the system, and realizes the reasonable generation of data cache to ensure that the cache frequency adapts to actual needs.
Smart Images

Figure CN118568137A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data caching method, device, equipment and medium. Background Art
[0002] In data services, active caching is increasingly used. Active caching is a predictive data management strategy that can load hot data to local media to increase data access speed and reduce database pressure. However, high-frequency active caching can affect the normal operation of local, third-party and / or databases. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a data caching method, apparatus, device and medium.
[0004] According to one aspect of the present disclosure, there is provided a data caching method, comprising:
[0005] Acquire a preset frequency adjustment parameter and a preset cache parameter, wherein the preset cache parameter includes at least one of an idle parameter, a response parameter, and a database parameter;
[0006] Acquire target data, and determine a cache generation coefficient according to the preset cache parameter and the target data, wherein the target data includes at least one of a local resource idle rate, an external response time, and database data;
[0007] A target cache generation frequency is determined according to the preset frequency adjustment parameter and the cache generation coefficient, and data caching is controlled based on the target cache generation frequency.
[0008] According to another aspect of the present disclosure, there is provided a data cache device, comprising:
[0009] An acquisition module, used to acquire a preset frequency adjustment parameter and a preset cache parameter, wherein the preset cache parameter includes at least one of an idle parameter, a response parameter and a database parameter;
[0010] A determination module, configured to obtain target data and determine a cache generation coefficient according to the preset cache parameters and the target data, wherein the target data includes at least one of a local resource idle rate, an external response time, and database data;
[0011] A generation module is used to determine a target cache generation frequency according to the preset frequency adjustment parameter and the cache generation coefficient, and control data cache based on the target cache generation frequency.
[0012] According to another aspect of the present disclosure, an electronic device is provided, including: a processor; and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes the above-mentioned data caching method.
[0013] According to another aspect of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the above data caching method.
[0014] The above-mentioned data caching method and device provided in the embodiment of the present disclosure obtains preset frequency adjustment parameters and preset cache parameters, wherein the preset cache parameters include at least one of idle parameters, response parameters and database parameters; obtains target data, and determines the cache generation coefficient according to the preset cache parameters and the target data, wherein the target data includes at least one of the local resource idle rate, external response time and database data; determines the target cache generation frequency according to the preset frequency adjustment parameters and the cache generation coefficient, and controls the data cache based on the target cache generation frequency. In the above scheme, the cache generation coefficient is determined according to the preset cache parameters and the target data representing the data cache situation of at least one dimension, and based on the cache generation coefficient, the target cache generation frequency matching the current data cache situation under the limit of the preset frequency adjustment parameters is determined, and the data cache is controlled by the target cache generation frequency, so that the generation speed of the data cache is controlled according to the cache influence parameter of at least one dimension, so that the target cache generation frequency finally generated is within a suitable range and adapted to the actual data cache situation of at least one party at present, reducing the impact of the data cache on the local, third party and / or database, and ensuring stability while realizing data caching.
[0015] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] Figure 1 A flowchart of a data caching method provided by an embodiment of the present disclosure;
[0019] Figure 2 A flowchart of another data caching method provided by an embodiment of the present disclosure;
[0020] Figure 3 A flowchart of another data caching method provided by an embodiment of the present disclosure;
[0021] Figure 4 A schematic diagram of a data caching method provided by an embodiment of the present disclosure;
[0022] Figure 5 A schematic diagram of the structure of a data cache device provided in an embodiment of the present disclosure;
[0023] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0025] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0026] The term "including" and its variations used in the present disclosure are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0027] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0028] One or more of the following problems may exist during the active caching process: First, the operation of the active caching task affects local business. Specifically, the operation of the active caching task will cause a surge in the number of visits to the localized medium, consume local resources, and thus affect the normal operation of the local business. Second, the operation of the active caching task affects third-party business. Specifically, in order to obtain hot data for caching in the active caching task, third-party data will be pulled, and a large number of requests will be made to the third party, resulting in a surge in third-party visits, affecting the performance and stability of the third-party business, making it difficult for the third-party business to operate normally. Third, the operation of the active caching task affects the database (Database, DB). Specifically, in order to obtain hot data, the active cache will continuously read and write the database, resulting in a surge in database visits, thereby affecting the normal operation of the database business.
[0029] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0030] In order to improve at least one of the above problems, the embodiments of the present disclosure provide a data caching method, apparatus, device and medium, which are described below for ease of understanding.
[0031] Figure 1 The present invention provides a flow chart of a data caching method provided in an embodiment of the present invention. The method can be executed by a data caching device, wherein the device can be implemented by software and / or hardware and can generally be integrated in an electronic device. Figure 1 As shown, the method mainly includes the following steps S101 to S103:
[0032] Step 101: Obtain preset frequency adjustment parameters and preset cache parameters, wherein the preset cache parameters include at least one of idle parameters, response parameters, and database parameters.
[0033] Among them, the preset frequency adjustment parameter may be a pre-set standard parameter to assist in frequency adjustment, and the preset frequency adjustment parameter may be used to limit the value range of the target cache generation frequency that is finally generated and / or limit the speed of adjusting the cache generation frequency. Frequency adjustment may be understood as adjusting the data generation speed of the active cache. The frequency may be the execution frequency of the minimum execution unit in the active caching process, and the granularity of the minimum execution unit may be set according to user needs, etc., and this embodiment does not impose any restrictions. For example, the minimum execution unit may include any one of an interface call, a database access, a task execution, and a complete data chain process. This embodiment does not impose any restrictions on the value of the preset cache parameter.
[0034] The idle parameter may be a preset extreme value of the resource idle rate. The response parameter may be a preset extreme value of the average time length for responding to a request. The database parameter may be an extreme value of the hardware state set for the database. The database parameter may include a database idle parameter and / or a database response parameter. The database idle parameter may be a preset extreme value of the resource idle rate of the database. The database idle parameter may be the same as the value of the idle parameter. The database response parameter may be a preset extreme value of the time length for responding to a local database request, and the database response parameter may be the same as the value of the response parameter. A database is a data set organized according to a certain data model and stored in a secondary memory. The database may be a provider of hotspot data for active caching. This embodiment does not limit the number of databases, and the number of databases may be one or more.
[0035] In the disclosed embodiment, the user may set the corresponding preset frequency adjustment parameter and / or preset cache parameter according to his / her own needs. Alternatively, the preset adjustment parameter and / or preset cache parameter may be a default value pre-written into the data cache device. The data cache device reads the preset frequency adjustment parameter and preset cache parameter.
[0036] Step 102: Obtain target data, and determine a cache generation coefficient according to preset cache parameters and the target data, wherein the target data includes at least one of a local resource idle rate, an external response time, and database data.
[0037] Among them, the target data can be data that characterizes the hardware and / or software occupancy of one or more parties that are actively caching at the current moment. The cache generation coefficient can be a coefficient used to adjust the standard value of the generation frequency of the active cache by percentage. The local resource idle rate can be a parameter that characterizes the idleness of local resources at the current moment. The external response time can be the average length of time required for a third party to respond to a local data request at the current moment. This embodiment does not limit the calculation period of the external response time. For example, the calculation period can be 1 minute. The third party can be a device that provides the data required for active caching through an interface. The local data request can be a task request issued locally to obtain hot spot data. The database data can be a parameter that characterizes the hardware and / or software occupancy of the database at the current moment.
[0038] Figure 2 A flow chart of another data caching method provided by an embodiment of the present disclosure is shown as follows: Figure 2 As shown, in some embodiments of the present disclosure, when the preset cache parameter is an idle parameter and the target data is a local resource idle rate, the cache generation coefficient is determined according to the preset cache parameter and the target data, including:
[0039] Step 201: Determine the minimum value of the CPU idle rate, memory idle rate and connection idle rate included in the local resource idle rate as the target idle rate.
[0040] Among them, the CPU idle rate can be the proportion of the CPU idle time in a preset time period, and the value range of the CPU idle rate can be between 0 and 100. The CPU is the computing and control core of the computer system, and the CPU can be the final execution unit of information processing and program running. The memory idle rate can be the proportion of unused memory (Memory) to the total memory, and the value range of the memory idle rate can be between 0 and 100. Memory is an important component of a computer, also known as internal memory or main memory. The memory is used to temporarily store the computing data in the CPU and the data exchanged with external memory such as a hard disk. The connection idle rate can be the proportion of the number of idle connections to the maximum number of connections, and the value range of the connection idle rate can be between 0 and 100. The target idle rate can be the idle rate that is finally determined to participate in the calculation of the first cache generation coefficient. The target idle rate can be the minimum value of 1 CPU idle rate, 1 memory idle rate, and 1 connection idle rate corresponding to 1 local service. Or, the target idle rate can be the minimum value of multiple CPU idle rates, multiple memory idle rates, and multiple connection idle rates corresponding to multiple local services.
[0041] In this embodiment, for each local service running locally, the data cache device can start the corresponding local detection mechanism, and then obtain the CPU idle rate and memory idle rate of each local service, and obtain the number of active connections of the local service at the current moment. The difference between the maximum number of connections and the number of active connections is divided by the maximum number of connections to obtain the connection idle rate of each local service. The minimum value among the CPU idle rate, memory idle rate, and connection idle rate is taken as the target idle rate. For example, if the minimum value among the CPU idle rate, memory idle rate, and connection idle rate is Bi, then the target idle rate is Bi.
[0042] Step 202: If the target idle rate is greater than or equal to the minimum idle rate in the idle parameters, determine a first idle difference between the target idle rate and the minimum idle rate, and a second idle difference between 100 and the minimum idle rate, and determine the ratio of the first idle difference to the second idle difference as the first cache generation coefficient in the cache generation coefficient; otherwise, determine the first cache generation coefficient in the cache generation coefficient to be zero.
[0043] The minimum idle rate may be a preset minimum value of the resource idle rate. The first idle difference may be a difference between the target idle rate and the minimum idle rate. The second idle value may be a difference between 100 and the minimum idle limit. The first cache generation coefficient may be a cache generation coefficient determined based on the resource idle situation dimension of the local service.
[0044] In this embodiment, the data cache device can determine the first cache generation coefficient in the cache generation coefficient by calculation according to the minimum idle rate and the target idle rate in the idle parameters. Specifically, after determining the target idle rate, the data cache device can determine whether the difference between the target idle rate and the minimum idle rate is greater than or equal to zero, that is, determine whether the target idle rate at the current moment is greater than or equal to the minimum idle rate. If so, calculate the difference between the target idle rate and the minimum idle rate to obtain the first idle difference. And calculate the difference between 100 and the minimum idle rate to obtain the second idle difference. Calculate the ratio of the first idle difference to the second idle difference to obtain the first cache generation coefficient. If the difference between the target idle rate and the minimum idle rate is less than zero, that is, the target idle rate is less than the minimum idle rate, then set the first cache generation coefficient to zero.
[0045] For example, if the target idle rate is Bi and the minimum idle rate is R1, when Bi-Rl≥0, the first cache generation coefficient is determined to be (Bi-Rl) / (100-Rl); when Bi-Rl<0, the first cache generation coefficient is determined to be 0.
[0046] In the above scheme, the local CPU idle rate, memory idle rate, and connection idle rate are obtained, and the first cache generation coefficient is obtained by calculation. The cache generation frequency is affected by the first generation coefficient, so that the final determined cache generation frequency adapts to the actual local resource occupancy at the current moment.
[0047] Figure 3 A flowchart of another data caching method provided by an embodiment of the present disclosure is shown as follows: Figure 3 As shown, in some embodiments of the present disclosure, when the preset cache parameter is a response parameter and the target data is an external response time, determining a cache generation coefficient according to the preset cache parameter and the target data includes:
[0048] Step 301: Determine the maximum value of the external response time as the target response time.
[0049] The target response time may be the response time finally determined to participate in the calculation of the second cache generation coefficient.
[0050] In this embodiment, the data cache device can start a detection mechanism for third-party services. After the local service initiates a local data request to the third party, each local data request has a corresponding third-party interface response time. The response time is obtained, and the average response time of each third-party interface in the calculation cycle is calculated once every calculation cycle to obtain the external response time corresponding to each third-party interface. The maximum value of the external response time is determined as the target response time. The target response time is calculated once every calculation cycle. For example, if the calculation cycle is 1 minute, the average response time of each third-party interface is calculated every minute to obtain the external response time of the third-party interface in the calculation cycle, and multiple external response times such as At1 and At2 are obtained. Among them, At1 and At2 respectively represent the external response times of different third-party interfaces. The maximum value of multiple external response times is determined as the target response time Mat.
[0051] Step 302: If the target response time is less than or equal to the maximum response time in the response parameter, the ratio of the response difference between the maximum response time and the target response time to the maximum response time is determined as the second cache generation coefficient in the cache generation coefficient; otherwise, the second cache generation coefficient in the cache generation coefficient is determined to be zero.
[0052] The maximum response time may be a preset maximum value of the average time length for responding to local requests, and the response difference may be a difference between the maximum response time and the target response time.
[0053] In this embodiment, the data cache device can determine the second cache generation coefficient in the cache generation coefficient by calculation according to the maximum response time in the response parameter and the target response time. Specifically, after determining the target response time, the data cache device can determine whether the difference between the target response time and the maximum response time is less than or equal to zero, that is, determine whether the target response time at the current moment is less than or equal to the maximum response time. If so, calculate the difference between the maximum response time and the target response time to obtain the response difference. And calculate the ratio of the response difference to the maximum response time to obtain the second cache generation coefficient. If the difference between the target response time and the maximum response time is greater than zero, that is, the target response time is greater than the maximum response time, the second cache generation coefficient is set to zero.
[0054] For example, if the target response time is Mat and the maximum response time is Mt, then when Mt-Mat≥0, the second cache generation coefficient is determined to be (Mt-Mat) / Mt; when Mt-Mat<0, the second cache generation coefficient is determined to be 0.
[0055] In the above scheme, the external response time of the third-party interface in the active cache is obtained, and the second cache generation coefficient is calculated based on the external response time. The cache generation frequency is affected by the second generation coefficient, so that the final determined cache generation frequency adapts to the actual resource occupancy of the third party at the current moment.
[0056] In some embodiments of the present disclosure, when the preset cache parameter is a database parameter, the target data is database data, and the database data includes a database resource idle rate and / or a database response time, determining a cache generation coefficient according to the preset cache parameter and the target data includes:
[0057] If the database resource idle rate is obtained, the third cache generation coefficient in the cache generation coefficient is determined according to the database resource idle rate and the idle parameter; otherwise, the third cache generation coefficient in the cache generation coefficient is determined according to the database response time and the response parameter.
[0058] The database resource idle rate may be a parameter characterizing the idleness of database resources at the current moment. The third cache generation coefficient may be a cache generation coefficient determined based on the actual resource occupancy of the database. The database response time may be the average time required for the database to respond to a local data request at the current moment. This embodiment does not limit the calculation period of the database response time, for example, the calculation period may be 1 minute.
[0059] In this embodiment, the data cache device can determine whether the database resource idle rate is obtained. If the database resource idle rate is obtained, the third cache generation coefficient is calculated based on the database resource idle rate and the idle parameter. If the database resource idle rate cannot be obtained due to reasons such as access rights, the database response time is obtained, and the third cache generation coefficient is determined based on the database response time and the response parameter.
[0060] In the above scheme, since the database resource idle rate can more accurately describe the current database resource occupancy than the database response time, when the database resource idle rate is obtained, the third cache generation coefficient is calculated based on the database resource idle rate first, which improves the accuracy of the third cache generation coefficient. And when the database resource idle rate cannot be obtained, the third cache generation coefficient is calculated based on the database response time, so that the application scenarios covered by the data caching method are more extensive.
[0061] In some embodiments of the present disclosure, determining a third cache generation coefficient in the cache generation coefficient according to the database resource idle rate and the idle parameter includes:
[0062] Step a1: Determine the minimum value among the CPU idle rate, memory idle rate and connection idle rate included in the database resource idle rate as the database idle rate.
[0063] The database idle rate may be an idle rate participating in the calculation of the third cache generation coefficient. The database idle rate may be a minimum value among a CPU idle rate, a memory idle rate, and a connection idle rate corresponding to a database service. Alternatively, the database idle rate may be a minimum value among multiple CPU idle rates, multiple memory idle rates, and multiple connection idle rates corresponding to multiple database services.
[0064] In this embodiment, for each database service, the data cache device can obtain the CPU idle rate and memory idle rate of each database service, and obtain the number of active connections of the database service at the current moment, and divide the difference between the maximum number of connections of the database and the number of active connections by the maximum number of connections of the database to obtain the connection idle rate of each database service. The minimum value among the CPU idle rate, the memory idle rate, and the connection idle rate is taken as the database idle rate. For example, if the minimum value among the CPU idle rate, the memory idle rate, and the connection idle rate is Bi', then the database idle rate is Bi'.
[0065] Step a2: If the database idle rate is greater than or equal to the minimum idle rate in the idle parameters, determine the first database idle difference between the database idle rate and the minimum idle rate, and the second idle difference between 100 and the minimum idle rate, and determine the ratio of the first database idle difference to the second database idle difference as the third cache generation coefficient in the cache generation coefficient; otherwise, determine the third cache generation coefficient in the cache generation coefficient to be zero.
[0066] The first database idle difference may be a difference between a database idle rate and a minimum idle rate.
[0067] In this embodiment, the data cache device can determine the third cache generation coefficient in the cache generation coefficient by calculation according to the minimum idle rate in the idle parameters and the database idle rate. Specifically, after determining the database idle rate, the data cache device can determine whether the difference between the database idle rate and the minimum idle rate is greater than or equal to zero, that is, determine whether the database idle rate at the current moment is greater than or equal to the minimum idle rate. If so, calculate the difference between the database idle rate and the minimum idle rate to obtain the first database idle difference. And calculate the difference between 100 and the minimum idle rate to obtain the second idle difference. Then calculate the ratio of the first database idle difference to the second idle difference to obtain the third cache generation coefficient. If the difference between the database idle rate and the minimum idle rate is less than zero, that is, the database idle rate is less than the minimum idle rate, then set the third cache generation coefficient to zero.
[0068] For example, if the database idle rate is Bi' and the minimum idle rate is R1, then when Bi'-Rl≥0, the third cache generation coefficient is determined to be (Bi'-Rl) / (100-Rl); when Bi'-Rl<0, the third cache generation coefficient is determined to be 0.
[0069] In the above scheme, the CPU idle rate, memory idle rate, and connection idle rate of the database are obtained, and a third cache generation coefficient is calculated. The cache generation frequency is affected by the third generation coefficient, so that the final determined cache generation frequency adapts to the actual resource occupancy of the database at the current moment.
[0070] In some embodiments of the present disclosure, determining a third cache generation coefficient in the cache generation coefficient according to the database response time and the response parameter includes:
[0071] Step b1: determine the maximum value of the database response time as the target database response time.
[0072] The target database response time may be a response time involved in calculating the third cache generation coefficient.
[0073] In this embodiment, the data cache device can start a detection mechanism for the database service. In the process of the local service initiating a local data request to the database, each instance of the database service has a corresponding database response time. The response time is obtained, and the average response time of each database in the calculation cycle is calculated once every calculation cycle to obtain the corresponding database response time. The maximum value of the database response time is determined as the target database response time. The target database response time is calculated once every calculation cycle. For example, if the calculation cycle is 1 minute, the average response time of each database is calculated every minute to obtain the database response time of the database in the calculation cycle, and multiple database response times such as At1', At2' are obtained. Among them, At1' and At2' respectively represent the database response times of different databases. The maximum value of multiple database response times is determined as the target database response time Mat'.
[0074] Step b2: If the target database response time is less than or equal to the maximum response time in the response parameter, the ratio of the response database difference between the maximum response time and the target database response time to the maximum response time is determined as the third cache generation coefficient in the cache generation coefficient; otherwise, the third cache generation coefficient in the cache generation coefficient is determined to be zero.
[0075] The response database difference may be a difference between a maximum response time and a target database response time.
[0076] In this embodiment, the data cache device can determine the third cache generation coefficient in the cache generation coefficient by calculation according to the maximum response time in the response parameter and the target database response time. Specifically, after determining the target database response time, the data cache device can determine whether the difference between the target database response time and the maximum response time is less than or equal to zero, that is, determine whether the target database response time at the current moment is less than or equal to the maximum response time. If so, calculate the difference between the maximum response time and the target database response time to obtain the response database difference. And calculate the ratio of the response database difference to the maximum response time to obtain the third cache generation coefficient. If the difference between the target database response time and the maximum response time is greater than zero, that is, the target database response time is greater than the maximum response time, the third cache generation coefficient is set to zero.
[0077] For example, if the target database response time is Mat' and the maximum response time is Mt, then when Mt-Mat'≥0, the third cache generation coefficient is determined to be (Mt-Mat') / Mt; when Mt-Mat'<0, the third cache generation coefficient is determined to be 0.
[0078] In the above scheme, the database response time of the database in the active cache is obtained, and the third cache generation coefficient is calculated. The cache generation frequency is affected by the third generation coefficient, so that the final determined cache generation frequency adapts to the actual resource occupancy of the database at the current moment.
[0079] Step 103: Determine a target cache generation frequency according to a preset frequency adjustment parameter and a cache generation coefficient, and control data caching based on the target cache generation frequency.
[0080] The target cache generation frequency may be a generation speed of the active cache that is finally determined. The data may be hotspot data cached by the active cache, and the data may be data obtained from a third-party interface or database.
[0081] In this embodiment, after determining the cache generation coefficient, the data cache device can adjust the parameters in the preset frequency adjustment parameters based on the cache generation coefficient to obtain the target cache generation frequency, and locally control the data cache frequency of the active cache based on the target cache generation frequency.
[0082] In some embodiments of the present disclosure, determining a target cache generation frequency according to a preset frequency adjustment parameter and a cache generation coefficient includes:
[0083] At least one cache generation frequency corresponding to at least one coefficient in the cache generation coefficient is determined according to the maximum frequency and the minimum frequency in the preset frequency adjustment parameter; and the minimum value of the at least one cache generation frequency is determined as the target cache generation frequency.
[0084] Among them, the maximum frequency can be the maximum value of the pre-set target cache generation frequency. This embodiment does not limit the value of this maximum frequency. The maximum frequency can be the generation frequency of hot data when the occupancy rate of the local central processing unit is the maximum occupancy rate. The minimum frequency can be the minimum value of the pre-set target cache generation frequency. This embodiment does not limit the value of this minimum frequency. The minimum frequency can be the generation frequency of hot data when the occupancy rate of the local central processing unit is the minimum occupancy rate.
[0085] In this embodiment, for the cache generation coefficient, the data cache device can multiply the maximum frequency by the cache generation coefficient to obtain a candidate frequency. If the candidate frequency is greater than or equal to the minimum frequency, the cache generation frequency corresponding to the cache generation coefficient is determined as the candidate frequency. If the candidate frequency is less than the minimum frequency, the cache generation frequency corresponding to the cache generation coefficient is determined as the minimum frequency. Furthermore, at least one cache generation frequency corresponding to at least one cache generation coefficient is obtained, and the minimum value among the at least one cache generation frequency is determined as the target cache generation frequency.
[0086] For example, if the preset cache parameters include an idle parameter, the target data includes the local resource idle rate, and the first cache generation coefficient in the cache generation coefficient is Ri, and the maximum frequency is Mi and the minimum frequency is Li. Then, for the candidate frequency LCi corresponding to the first cache generation frequency, LCi = Mi * Ri. If LCi ≥ Li, the cache generation frequency is determined as LCi. If LCi < Li, the first cache generation frequency is determined as Li.
[0087] If the preset cache parameters include a response parameter, the target data includes the external response time, and the second generation coefficient in the cache generation coefficient is Ti, and the maximum frequency is Mi and the minimum frequency is Li. Then, for the candidate frequency TCi corresponding to the second cache generation frequency, TCi = Mi * Ti. If TCi ≥ Li, the cache generation frequency is determined as TCi. If TCi < Li, the second cache generation frequency is determined as Li.
[0088] If the preset cache parameters include database parameters, the target data includes the database resource idle rate in the database data, and the third cache generation coefficient in the cache generation coefficient is Ri', and the maximum frequency is Mi and the minimum frequency is Li. Then, for the candidate frequency DCi corresponding to the third cache generation frequency, DCi = Mi * Ri'. If DCi ≥ Li, the cache generation frequency is determined as DCi. If DCi < Li, the third cache generation frequency is determined as Li.
[0089] If the preset cache parameter includes a database parameter, the target data includes the database response time in the database data, the third generation coefficient in the cache generation coefficient is Ti', if the maximum frequency is Mi, and the minimum frequency is Li. Then for the candidate frequency DCi corresponding to the third cache generation frequency, DCi = Mi * Ti'. If DCi ≥ Li, the cache generation frequency is determined as DCi; if DCi < Li, the third cache generation frequency is determined as Li.
[0090] Further, if the cache generation frequency includes a first cache generation frequency, a second cache generation frequency, and a third cache generation frequency, the minimum value among the first cache generation frequency, the second cache generation frequency, and the third cache generation frequency is determined as the target cache generation frequency. Since this target cache generation frequency is the cache generation frequency generated for detecting and collecting the states of multiple parties, based on this target cache generation frequency, the impact of the data generation process of active caching on local services, third-party services, and the database system can be reduced, thereby improving the stability of the overall system.
[0091] In some embodiments of the present disclosure, controlling data caching based on the target cache generation frequency includes:
[0092] Adjust the target frequency according to the minimum frequency, frequency step, and frequency step interval in the preset frequency adjustment parameter until the real-time cache generation frequency is equal to the target cache generation frequency; perform a target operation based on the target frequency, and perform data caching according to the real-time cache generation frequency during the target operation.
[0093] Among them, the target frequency can be the frequency for performing the target operation. The type of this target frequency is not limited in this embodiment. Optionally, the target frequency includes at least one of an interface call frequency, a database access frequency, and a task execution frequency. The interface call frequency can be the frequency for calling a third-party interface. The database access frequency can be the frequency for accessing the database. The task execution frequency can be the frequency for locally executing an active caching task.
[0094] The frequency step can be the minimum unit for adjusting the cache generation frequency, and the frequency step is not limited in this embodiment. The frequency step interval can be the time interval between two adjacent cache generation frequency adjustments, and the frequency step interval is not limited in this embodiment. The real-time cache generation frequency can be the generation frequency of real-time cache data, and there can be a numerical correspondence relationship between the real-time cache generation frequency and the target frequency. The target operation can be an operation performed during the active caching process. Optionally, the target operation includes at least one of an interface call, a database access, and a task execution. The interface call can be the call to a third-party interface. The database access can be the access to the database. The task execution frequency can be the execution frequency of the local active caching task.
[0095] In this embodiment, the minimum frequency, frequency step, and frequency step interval are pre-set in the preset frequency adjustment parameters. The data cache device can use the minimum frequency as the initial target frequency, and add the frequency step every frequency step interval on the basis of the current target frequency to obtain a new target frequency, and perform the target operation based on the new target frequency. The corresponding real-time cache generation frequency also changes periodically with the change of the target frequency. During the target operation, the frequency of data caching is the real-time cache generation frequency until the real-time cache generation frequency reaches the target cache generation frequency, then the adjustment of the target frequency is terminated, and the data caching is maintained at the target cache generation frequency.
[0096] In the above scheme, a slow adjustment of the data cache frequency is achieved, which avoids the impact on the system caused by excessive amount of cached data after adjustment and improves the stability of the system during the adjustment process.
[0097] In summary, the above data caching method provided by the embodiment of the present disclosure obtains preset frequency adjustment parameters and preset cache parameters, wherein the preset cache parameters include at least one of idle parameters, response parameters and database parameters; obtains target data, and determines the cache generation coefficient according to the preset cache parameters and the target data, wherein the target data includes at least one of the local resource idle rate, external response time and database data; determines the target cache generation frequency according to the preset frequency adjustment parameters and the cache generation coefficient, and controls the data cache based on the target cache generation frequency. In the above scheme, the cache generation coefficient is determined according to the preset cache parameters and the target data representing the data cache situation of at least one dimension, and based on the cache generation coefficient, the target cache generation frequency matching the current data cache situation under the limit of the preset frequency adjustment parameters is determined, and the data cache is controlled by the target cache generation frequency, so that the generation speed of the data cache is controlled according to the cache influence parameter of at least one dimension, so that the target cache generation frequency finally generated is within a suitable range and adapted to the actual data cache situation of at least one party at present, reducing the impact of the data cache on the local, third party and / or database, and ensuring stability while realizing data caching.
[0098] Next, the data caching method in the embodiment of the present disclosure is further described by using a specific example.
[0099] The maximum frequency is set to Mi times / second, the minimum frequency is set to Li times / second, the frequency step is set to I times, and the frequency step interval is set to T seconds. The minimum frequency is used as the initial target frequency. The local active cache task is started regularly, the detection mechanism is started, and the target cache generation frequency is determined. The active cache task speed starts from Li times / second and increases by I times every T seconds, with a maximum of no more than Mi times / second and reaching the target cache generation frequency.
[0100] The target cache generation frequency is the minimum of the first cache generation frequency, the second cache generation frequency, and the third cache generation frequency.
[0101] The first cache generation frequency can be the cache generation frequency determined locally. The determination process of the first cache generation frequency can include: The data cache device starts the local detection mechanism. The data cache device obtains the CPU idle rate of the local service, obtains the memory idle rate of the local service, obtains the connection idle rate of the local connection, where the connection idle rate is the result obtained by dividing the difference between the maximum number of connections and the current number of active connections by the maximum number of connections. And obtain the above-mentioned idle rates of each medium locally. Obtain multiple groups of idle rates corresponding to the media of multiple locals. Determine the minimum value among all the obtained idle rates to obtain the target idle rate Bi. If the minimum idle rate is Rl, when Bi - Rl ≥ 0, the first cache generation coefficient Ri is: (Bi - Rl) / (100 - Rl). When Bi - Rl < 0, the first cache generation coefficient Ri is set to 0. If the maximum frequency is Mi and the minimum frequency is Li, calculate the candidate frequency LCi corresponding to the first cache generation frequency = Mi * Ri. If LCi ≥ Li, then determine the first cache generation frequency as LCi. If LCi < Li, then determine the first cache generation frequency as Li.
[0102] The second cache generation frequency can be the cache generation frequency determined based on a third party. The determination process of the second cache generation frequency can include: The data cache device starts the third-party detection mechanism. During the task request process, each request has a response time. Obtain the response time of each third-party interface for each request, and calculate the average response time of each third-party interface within that minute once per minute to obtain the external response time. For n third-party interfaces, obtain n external response times At1, At2,..., Atn, and determine the maximum value among the external response times as the target response time Mat. Determine the target response time Mat once per minute. If the maximum response time is Mt, when Mt - Mat ≥ 0, the second cache generation coefficient Ti = (Mt - Mat) / Mt. When Mt - Mat < 0, the second cache generation coefficient Ti is set to 0. If the maximum frequency is Mi and the minimum frequency is Li, calculate the candidate frequency TCi corresponding to the second cache generation frequency = Mi * Ti. If TCi ≥ Li, then determine the second cache generation frequency as TCi. If TCi < Li, then determine the second cache generation frequency as Li.
[0103] The third cache generation frequency can be the cache generation frequency determined based on the database. The determination process of the third cache generation frequency can include: when the database resource idle rate is obtained, determining the third cache generation coefficient according to the database resource idle rate and the idle parameter; when the database resource idle rate is not obtained, determining the third cache generation coefficient according to the database response time and the response parameter.
[0104] Determining the third cache generation coefficient according to the database resource idle rate and the idle parameter includes: the data cache device obtains the central processing unit idle rate, memory idle rate, and connection idle rate of the database service. The connection idle rate of the database is the value obtained by dividing the difference between the maximum connection number of the database and the active connection number of the current database by the maximum connection number of the database. Obtaining the above-mentioned idle rates of each database to obtain multiple groups of idle rates corresponding to multiple databases. Determining the minimum value among all the obtained idle rates to obtain the database idle rate Bi'. If the minimum idle rate is Rl, when Bi' - Rl ≥ 0, the value of the third cache generation coefficient is Ri', and Ri' = (Bi' - Rl) / (100 - Rl). When Bi' - Rl < 0, the value of the third cache generation coefficient is set to 0. If the maximum frequency is Mi and the minimum frequency is Li, calculate the candidate frequency DCi corresponding to the third cache generation frequency, DCi = Mi * Ri'. If DCi ≥ Li, then determine the third cache generation frequency as DCi. If DCi < Li, then determine the third cache generation frequency as Li.
[0105] Determining the third cache generation coefficient according to the database response time and the response parameter includes: during the task request process, each instance has a response time. Obtain the response time of each instance corresponding to the database, and calculate the average response time of each database within that minute every minute to obtain the database response time. For n databases, obtain multiple database response times such as At1', At2', etc., and determine the maximum value among the database response times as the target database response time Mat'. Determine the target database response time Mat' once every minute. If the maximum response time is Mt, when Mt - Mat' ≥ 0, the value of the third cache generation coefficient is Ti', and Ti' = (Mt - Mat') / Mt. When Mt - Mat' < 0, the value of the third cache generation coefficient is set to 0. If the maximum frequency is Mi and the minimum frequency is Li, calculate the candidate frequency DCi corresponding to the third cache generation frequency, DCi = Mi * Ti'. If TCi ≥ Li, then determine the third cache generation frequency as DCi. If DCi < Li, then determine the third cache generation frequency as Li.
[0106] Figure 4 A schematic diagram of a data caching method provided by an embodiment of the present disclosure, as Figure 4As shown, in the data caching method, the local detector obtains the local resource idle rate, the third-party detector detects multiple interfaces such as interface 1 and interface 2 of the third party to obtain the external response time, and the database detector detects multiple databases such as database 1 and database 2 to obtain the database resource idle rate or database response time. The data caching device determines the target cache generation frequency based on the above-mentioned local resource idle rate, external response time, and database resource idle rate. Alternatively, the data caching device determines the target cache generation frequency based on the above-mentioned local resource idle rate, external response time, and database response time. Furthermore, the frequency of the data cache is adjusted to the target cache generation frequency in a slow start manner through a rate regulator.
[0107] The data caching method provided by the embodiment of the present disclosure, the calculation of the final target cache generation frequency involves the detection and collection of the status of multiple parties such as local, third-party, and database. Based on the target cache generation frequency, the interface call frequency, database access frequency, task delay duration, etc. can be adjusted, thereby reducing the impact of the cache generation process on the local business, third-party business, and database system, and improving the stability of the local, third-party, and database systems as a whole.
[0108] Corresponding to the aforementioned data caching method, the embodiment of the present disclosure further provides a data caching device, Figure 5 This is a schematic diagram of the structure of a data cache device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. Figure 5 As shown, the data cache device 500 includes:
[0109] An acquisition module 501 is used to acquire a preset frequency adjustment parameter and a preset cache parameter, wherein the preset cache parameter includes at least one of an idle parameter, a response parameter and a database parameter;
[0110] A determination module 502, configured to obtain target data and determine a cache generation coefficient according to the preset cache parameter and the target data, wherein the target data includes at least one of a local resource idle rate, an external response time, and database data;
[0111] The generating module 503 is configured to determine a target cache generation frequency according to the preset frequency adjustment parameter and the cache generation coefficient, and control data caching based on the target cache generation frequency.
[0112] In some implementations, when the preset cache parameter is an idle parameter and the target data is a local resource idle rate, the determination module 502 is configured to:
[0113] Determine that the minimum value among the CPU idle rate, memory idle rate and connection idle rate included in the local resource idle rate is the target idle rate;
[0114] If the target idle rate is greater than or equal to the minimum idle rate in the idle parameters, determine a first idle difference between the target idle rate and the minimum idle rate, and a second idle difference between 100 and the minimum idle rate, and determine the ratio of the first idle difference to the second idle difference as the first cache generation coefficient in the cache generation coefficient; otherwise, determine the first cache generation coefficient in the cache generation coefficient to be zero.
[0115] In some implementations, when the preset cache parameter is a response parameter and the target data is an external response time, the determination module 502 is configured to:
[0116] Determine the maximum value of the external response times as the target response time;
[0117] If the target response time is less than or equal to the maximum response time in the response parameters, the ratio of the response difference between the maximum response time and the target response time to the maximum response time is determined as the second cache generation coefficient in the cache generation coefficient; otherwise, the second cache generation coefficient in the cache generation coefficient is determined to be zero.
[0118] In some implementations, when the preset cache parameter is a database parameter, the target data is database data, and the database data includes a database resource idle rate and / or a database response time, the determination module 502 is used to:
[0119] If the database resource idle rate is obtained, determining a third cache generation coefficient in the cache generation coefficient according to the database resource idle rate and the idle parameter;
[0120] Otherwise, a third cache generation coefficient among the cache generation coefficients is determined according to the database response time and the response parameter.
[0121] In some implementations, the generating module 503 is used to:
[0122] Determine at least one cache generation frequency corresponding to at least one coefficient in the cache generation coefficient according to the maximum frequency and the minimum frequency in the preset frequency adjustment parameter;
[0123] A minimum value of the at least one cache generation frequency is determined as the target cache generation frequency.
[0124] In some implementations, the generating module 503 is used to:
[0125] Adjusting the target frequency according to the minimum frequency, frequency step, and frequency step interval in the preset frequency adjustment parameters until the real-time cache generation frequency is equal to the target cache generation frequency;
[0126] A target operation is performed based on the target frequency, and data is cached according to the real-time cache generation frequency during the target operation.
[0127] In some implementations, the target operation includes at least one of interface call, database access, and task execution, and the target frequency includes at least one of interface call frequency, database access frequency, and task execution frequency.
[0128] The data caching device provided in the embodiments of the present disclosure can execute the data caching method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device embodiment can refer to the corresponding process in the method embodiment, and will not be repeated here.
[0130] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0131] The exemplary embodiment of the present disclosure also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to cause the electronic device to perform the method according to the embodiment of the present disclosure when executed by the at least one processor.
[0132] The exemplary embodiments of the present disclosure also provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform the method according to the embodiments of the present disclosure.
[0133] The exemplary embodiments of the present disclosure further provide a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, the computer is used to enable the computer to perform the method according to the embodiments of the present disclosure.
[0134] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0135] In addition, the embodiment of the present disclosure may also be a computer-readable storage medium, on which a computer program instruction is stored, and the computer program instruction, when executed by a processor, causes the processor to execute the data caching method provided by the embodiment of the present disclosure. The computer-readable storage medium may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0136] refer to Figure 6 , a block diagram of an electronic device 600 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0137] like Figure 6As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0138] A plurality of components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 may be any type of device capable of inputting information to the electronic device 600, and the input unit 606 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 607 may be any type of device capable of presenting information, and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 608 may include, but is not limited to, a disk, an optical disk. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0139] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above. For example, in some embodiments, the data caching method can be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 600 via ROM 602 and / or communication unit 609. In some embodiments, the computing unit 601 can be configured to perform the data caching method in any other appropriate manner (e.g., by means of firmware).
[0140] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0141] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0142] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0143] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0144] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0145] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0146] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0147] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data caching method, comprising: Acquire a preset frequency adjustment parameter and a preset cache parameter, wherein the preset cache parameter includes at least one of an idle parameter, a response parameter, and a database parameter; Acquire target data, and determine a cache generation coefficient according to the preset cache parameter and the target data, wherein the target data includes at least one of a local resource idle rate, an external response time, and database data; A target cache generation frequency is determined according to the preset frequency adjustment parameter and the cache generation coefficient, and data caching is controlled based on the target cache generation frequency.
2. The data caching method according to claim 1, wherein: When the preset cache parameter is an idle parameter and the target data is a local resource idle rate, determining a cache generation coefficient according to the preset cache parameter and the target data includes: Determine that the minimum value among the CPU idle rate, memory idle rate and connection idle rate included in the local resource idle rate is the target idle rate; If the target idle rate is greater than or equal to the minimum idle rate in the idle parameters, determine a first idle difference between the target idle rate and the minimum idle rate, and a second idle difference between 100 and the minimum idle rate, and determine the ratio of the first idle difference to the second idle difference as the first cache generation coefficient in the cache generation coefficient; otherwise, determine the first cache generation coefficient in the cache generation coefficient to be zero.
3. The data caching method according to claim 1, wherein: When the preset cache parameter is a response parameter and the target data is an external response time, determining a cache generation coefficient according to the preset cache parameter and the target data includes: Determine the maximum value of the external response times as the target response time; If the target response time is less than or equal to the maximum response time in the response parameters, the ratio of the response difference between the maximum response time and the target response time to the maximum response time is determined as the second cache generation coefficient in the cache generation coefficient; otherwise, the second cache generation coefficient in the cache generation coefficient is determined to be zero.
4. The data caching method according to claim 1, wherein: When the preset cache parameter is a database parameter, the target data is database data, and the database data includes a database resource idle rate and / or a database response time, determining a cache generation coefficient according to the preset cache parameter and the target data includes: If the database resource idle rate is obtained, determining a third cache generation coefficient in the cache generation coefficient according to the database resource idle rate and the idle parameter; Otherwise, a third cache generation coefficient among the cache generation coefficients is determined according to the database response time and the response parameter.
5. The data caching method according to claim 1, wherein: Determining a target cache generation frequency according to the preset frequency adjustment parameter and the cache generation coefficient includes: Determine at least one cache generation frequency corresponding to at least one coefficient in the cache generation coefficient according to the maximum frequency and the minimum frequency in the preset frequency adjustment parameter; A minimum value of the at least one cache generation frequency is determined as the target cache generation frequency.
6. The data caching method according to claim 1, wherein: Controlling data cache based on the target cache generation frequency includes: Adjusting the target frequency according to the minimum frequency, frequency step, and frequency step interval in the preset frequency adjustment parameters until the real-time cache generation frequency is equal to the target cache generation frequency; A target operation is performed based on the target frequency, and data is cached according to the real-time cache generation frequency during the target operation.
7. The method of claim 6, wherein: The target operation includes at least one of interface calling, database access, and task execution, and the target frequency includes at least one of interface calling frequency, database access frequency, and task execution frequency.
8. A data cache device, comprising: An acquisition module, used to acquire a preset frequency adjustment parameter and a preset cache parameter, wherein the preset cache parameter includes at least one of an idle parameter, a response parameter and a database parameter; A determination module, configured to obtain target data and determine a cache generation coefficient according to the preset cache parameters and the target data, wherein the target data includes at least one of a local resource idle rate, an external response time, and database data; A generation module is used to determine a target cache generation frequency according to the preset frequency adjustment parameter and the cache generation coefficient, and control data cache based on the target cache generation frequency.
9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, enable the processor to perform the data caching method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program is used to execute the data caching method according to any one of claims 1 to 7.
Citation Information
Cited By
Generation management method for API (Application Program Interface)
CN120315784A
