CN112035526B - Data caching method, device, equipment and readable storage medium - Google Patents

Data caching method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN112035526B
CN112035526B CN202010903867.3A CN202010903867A CN112035526B CN 112035526 B CN112035526 B CN 112035526B CN 202010903867 A CN202010903867 A CN 202010903867A CN 112035526 B CN112035526 B CN 112035526B
Authority
CN
China
Prior art keywords
interface
time
cache
data
access
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010903867.3A
Other languages
Chinese (zh)
Other versions
CN112035526A (en
Inventor
李刘强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202010903867.3A priority Critical patent/CN112035526B/en
Publication of CN112035526A publication Critical patent/CN112035526A/en
Application granted granted Critical
Publication of CN112035526B publication Critical patent/CN112035526B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a data caching method, a device, equipment and a readable storage medium, wherein the caching time of an interface is obtained, the caching time of the interface is the storage time of data accessed by calling the interface in a cache, the caching time of the interface is updated in response to the invalidation of the caching data, the caching data is obtained by writing the data accessed by the interface into the cache, and the updated caching time of the interface is used as the storage time of the data in response to the accessing of the interface, and the data is written into the cache. It can be understood that the invalidation of the buffered data is at least related to the timeliness of the data, so that it can be seen that the data buffering method provided by the embodiment of the application can adaptively adjust the buffering time of the interface according to the invalidation of the buffered data, so that the buffering time of the interface is related to the timeliness of the data, and the hit rate of the buffered data is improved.

Description

Data caching method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a data caching method, device, apparatus, and readable storage medium.
Background
Along with the increase of the number of active users and the transaction amount of the mobile phone bank, the access amount of a background system of the mobile phone bank is larger and larger, and the system faces larger performance pressure. In order to relieve performance pressure caused by large access quantity of a background system of a mobile phone bank, interface data can be written into a cache from a system database, and the interface data can be directly read from the cache within the valid period of the cache data without accessing the background system and the system database. However, the cache hit rate in the prior art is low, and after the cache data is invalid, the background system and the database still need to be accessed again to read the data.
Disclosure of Invention
The application provides a data caching method, a device, equipment and a readable storage medium, which are as follows:
a data caching method, comprising:
obtaining the cache time of an interface, wherein the cache time of the interface is the storage time of data accessed by calling the interface in a cache;
in response to cache data invalidation, updating the cache time of the interface, wherein the cache data is obtained by writing the data accessed by the interface into a cache;
and responding to the interface to access the data, and writing the data into a cache by taking the updated cache time of the interface as the storage time of the data.
Optionally, obtaining the buffer time of the interface includes:
acquiring a preset access weight of the interface;
and multiplying the preset cache time by the access weight to obtain the cache time of the interface.
Optionally, acquiring a preset access weight of the interface includes:
collecting the accumulated access quantity of the interface, wherein the accumulated access quantity is the data access quantity of the interface in a preset period;
calculating an average access amount, wherein the average access amount is an average value of the accumulated access amounts of all interfaces in the period;
and calculating the ratio of the accumulated access quantity to the average access quantity as the access weight of the interface.
Optionally, in response to a cache data invalidation, updating the cache time of the interface includes:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
Optionally, reducing the buffering time of the interface includes:
reducing the buffer time of the interface by a preset first value to obtain a first buffer time of the interface;
if the first cache time of the interface is not smaller than a preset minimum threshold value, updating the cache time of the interface to the first cache time.
And if the first cache time of the interface is smaller than the minimum threshold value, updating the cache time of the interface to the minimum threshold value.
Optionally, increasing the buffering time of the interface includes:
increasing the buffer time of the interface by a preset second value to obtain a second buffer time of the interface;
if the second cache time of the interface is not greater than a preset maximum threshold value, updating the cache time of the interface to the second cache time;
and if the second cache time of the interface is greater than the maximum threshold, updating the cache time of the interface to the maximum threshold.
A data caching apparatus, comprising:
the buffer time determining unit is used for obtaining the buffer time of an interface, wherein the buffer time of the interface is the storage time of data accessed by calling the interface in a buffer;
a cache time updating unit, configured to update, in response to a cache data invalidation, the cache time of the interface, where the cache data is obtained by writing the data accessed by the interface into a cache;
and the data caching unit is used for responding to the data accessed by the interface and writing the data into a cache by taking the updated cache time of the interface as the storage time of the data.
Optionally, the cache time updating unit is configured to update the cache time of the interface in response to a cache data failure, including: the cache time updating unit is specifically configured to:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
A data caching apparatus comprising: a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the data caching method as described above.
A readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a data caching method as described above.
According to the data caching method, device and equipment and the readable storage medium, the caching time of the interface is obtained, the caching time of the interface is the storage time of the data accessed by the calling interface in the cache, the caching time of the interface is updated in response to the invalidation of the caching data, the caching data is obtained by writing the data accessed by the interface into the cache, and the updated caching time of the interface is used as the storage time of the data in response to the accessing of the interface, and the data is written into the cache. It can be understood that the invalidation of the buffered data is at least related to the timeliness of the data, so that it can be seen that the data buffering method provided by the embodiment of the application can adaptively adjust the buffering time of the interface according to the invalidation of the buffered data, so that the buffering time of the interface is related to the timeliness of the data, and the hit rate of the buffered data is improved.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a specific implementation of a data caching method according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a data caching method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a data caching device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a data caching device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The data caching method provided by the embodiment of the application is applied to, but not limited to, determining the caching time of the data of the interface in the mobile banking. An optional application scenario of this embodiment is: the mobile phone bank comprises n interfaces, in order to relieve the pressure of the system, the data accessed by the calling interfaces are written into the cache, when the data is required to be accessed again, the data is directly read from the cache, the embodiment is applied to determining the storage time of the data accessed by the calling interfaces in the cache, and the storage time of any data accessed by the calling interfaces in the embodiment is the same. It should be noted that the present embodiment may also be applied to determination of a buffering time of data in other scenarios, for example, determination of a buffering time of webpage information buffering data of a web site, which is not limited to this embodiment.
Fig. 1 is a flow chart of a data caching method according to an embodiment of the present application, as shown in fig. 1, may specifically include the following S101 to S111.
S101, collecting accumulated access quantity of each interface.
In this embodiment, the cumulative access amount of each interface is the data access amount of the interface in a preset period, that is, the data access amount of the interface is called in the preset period. It should be noted that, the method for collecting the cumulative access amount of the interface can be referred to the prior art.
S102, calculating the average access quantity of all interfaces.
In this embodiment, the average access amount of all interfaces is an average value of the cumulative access amounts of all interfaces.
For example, the number of interfaces is denoted as n, and the method of calculating the average value of the access amounts of all interfaces is described in formula (1), as follows:
wherein:n is the average access amount i For the cumulative access of any interface, i E [1, n ]]。
S103, calculating the access weight of the interface.
In this embodiment, the access weight of the interface is a ratio of the cumulative access amount of the interface to the average access amount, that is, a ratio of the access amount of the interface in a preset period to the average value of the access amounts of all the interfaces in the preset period, and it should be noted that the size of the access weight of the interface may represent the access frequency of the interface, for example, the larger the access weight of the interface, the higher the access frequency of the interface is.
Interface k is interface i For example, interface k i See formula (2), as follows:
wherein F is i For interface k i Access weight, N i For interface k i Is provided with a cumulative amount of access to (c) the system,is the average access volume.
S104, obtaining the initial buffer time of the interface.
In this embodiment, the initial buffer time of the interface is the buffer time of the interface at the initial time of the preset period, and the buffer time of the interface is the storage time of the data accessed by the calling interface in the buffer.
The method for calculating the initial buffering time of the interface comprises the following steps: multiplying the preset cache time by the access weight of the interface to obtain the initial cache time of the interface.
In this embodiment, the preset buffering time is set according to the actual requirement, and it should be noted that in the actual application, the preset buffering times of different interfaces are the same.
In this embodiment, the interface is used as interface k i For example, an interfacek i One specific calculation method of the initial buffering time of (2) can be seen in formula (3)
T i0 =T C *F i (3)
Wherein T is i0 For interface k i Initial buffering time of T C F for presetting the buffer time i For interface k i Is used for the access weight of (a).
When the access weights of the interfaces are calculated, the average access amount is the same, the access amount of the interfaces is in direct proportion to the access weight of the interfaces, that is, the higher the access weight of the interfaces with higher access amount is, the access frequency of the interfaces can be indicated by the access weight of any one interface, and because the preset cache time of the interfaces with different initial moments is the same, the initial cache time of the interfaces is in direct proportion to the access weight of the interfaces, the higher the access weight is, the higher the initial cache time is, that is, the higher the access frequency is, and the initial cache time is.
In summary, the method considers the influence of the access frequency on the cache time, determines different initial cache time for interfaces with different access frequencies, and if the cache time of the interface with high access frequency is long, the hit rate of the cache data of the interface is high.
And S105, responding to updating failure of the cache data, and reducing the cache time of the interface by a preset first value to obtain the first cache time of the interface.
In this embodiment, the cache data is obtained by writing the data accessed by the interface into the cache, and update failure of the cache data is triggered by update of the data.
It should be noted that, after the data accessed by any interface is written into the cache, cache data of the data is obtained, the data is updated in the system, and the cache data corresponding to the data in the cache is inconsistent with the data, so that the cache data is invalid.
It should be noted that, if the update failure of the cache data is the first failure (update failure or expiration failure) in the preset period, the cache time of the interface is the initial cache time of the interface, and the method for calculating the first cache time of the interface is as follows: subtracting a preset first value from the buffer time of the interface.
In the above example, in response to the update failure of the cache data, the first cache time calculation method of the interface is referred to formula (4), as follows:
T i1 =T i -ΔT sub (4)
wherein T is i1 For interface k i Is DeltaT sub Is a first numerical value, T i For interface k i When the cache time of the cache data is first invalid (update invalid or expiration invalid) in a preset period, T i =T i0
It should be noted that the first value may be set according to the update failure frequency of the cache data, and the first value is smaller than the initial cache time, and it is understood that the first value indicates the time-effectiveness of the cache data, and the higher the time-effectiveness of the cache data, that is, the higher the update frequency, the larger the first value.
S106, updating the buffer time of the interface to the first buffer time under the condition that the first buffer time of the interface is not smaller than a preset minimum threshold value.
In this embodiment, the minimum threshold is set according to actual requirements, and optionally, the minimum threshold is the minimum value in the buffering time of all interfaces, denoted as T min ,T min =min{T 1 ,T 2 ,...,T n }。
In the above example, if T i1 ≥T min Then update T i =T i1
And S107, updating the buffer time of the interface to the minimum threshold value under the condition that the first buffer time of the interface is smaller than the preset minimum threshold value.
In the above example, if T i1 <T min Then update T i =T min
And S108, in response to expiration failure of the cache data, increasing the cache time of the interface by a preset second value to obtain the second cache time of the interface.
In this embodiment, expiration of the cache data is triggered by expiration of the retention time of the data in the cache.
It should be noted that, if the update failure of the cache data is the first failure (update failure or expiration failure) in the preset period, the cache time of the interface is the initial cache time of the interface, and the method for calculating the second cache time of the interface is as follows: and increasing the buffer time of the interface by a preset second value.
In the above example, in response to expiration of the cache data, the second cache time calculation method of the interface is shown in formula (4), as follows:
T i2 =T i +ΔT add (4)
wherein T is i2 For interface k i Is DeltaT add At a second value, T i For interface k i When the cache data is invalidated for the first time (update invalidation or expiration invalidation) in a preset period, T i =T i0
It should be noted that the second value may be set according to the frequency of the expiration failure of the cache data, and it is understood that the second value indicates the timeliness of the interface, and when the timeliness of the interface is lower, that is, the update frequency is lower, the second value is larger.
And S109, updating the buffer time of the interface to the second buffer time under the condition that the second buffer time of the interface is not greater than a preset maximum threshold value.
In this embodiment, the maximum threshold is set according to actual requirements, and optionally, the maximum threshold is the maximum value in the buffering time of all interfaces, denoted as T max ,T max =max{T 1 ,T 2 ,...,T n }。
In the above example, if T i2 ≤T max Then update T i =T i2
S110, updating the buffer time of the interface to the maximum threshold value under the condition that the second buffer time of the interface is larger than the preset maximum threshold value.
In the above example, if T i1 >T max Then update T i =T max
It should be noted that, when the cache data is invalidated (in the first case or the second case), the cache data in the cache is deleted.
In addition, S105 to S107 take a first failure in a preset period as an update failure as an example, and S108 to S110 take a first failure in a preset period as an expiration failure, and the method of updating the buffer time of the interface, as shown in fig. 1, does not limit the sequence between S105 to S107 and S108 to S110.
And S111, responding to the interface access data, and writing the data into a cache by taking the updated cache time of the interface as the data storage time.
In this embodiment, the updated buffer time of the interface is used as a time tag for calling the data accessed by the interface, and the data is stored in the buffer, where the time tag is the storage time of the data, and specifically, refer to the prior art.
According to the data caching method provided by the embodiment of the application, the caching time of the interface is obtained, the caching time of the interface is the storage time of the data accessed by the calling interface in the cache, the caching time of the interface is updated in response to the invalidation of the caching data, wherein the caching data is obtained by writing the data accessed by the interface into the cache, and the updated caching time of the interface is used as the storage time of the data in response to the accessing of the interface, and the data is written into the cache. It can be understood that the invalidation of the buffered data is at least related to the timeliness of the data, so that it can be seen that the data buffering method provided by the embodiment of the application can adaptively adjust the buffering time of the interface according to the invalidation of the buffered data, so that the buffering time of the interface is related to the timeliness of the data, and the hit rate of the buffered data is improved.
Further, when the cache data update fails, the timeliness of the data accessed by the interface is high, so that the method reduces the cache time of the interface. When the cache data is out of date, the method indicates that the timeliness of the data accessed by the interface is low, so that the method increases the cache time of the interface, namely, the method can shorten the cache time of the interface with high timeliness and prolong the cache time of the interface with low timeliness.
Furthermore, the method considers the influence of the access frequency on the cache time, determines different initial cache time for interfaces with different access frequencies according to the access weight of the interfaces, and has long cache time for interfaces with high access frequency, thereby further improving the hit rate of cache data.
Compared with the prior art, the method has the advantages that the fixed cache time is set for all interfaces, the influence of timeliness of data and access frequency of the interfaces on the cache time is integrated, the cache time of each interface is determined in a self-adaptive mode, the hit rate of the cache data is improved on the premise that the data consistency is maintained, the access times of a system database are further reduced, the system performance pressure is relieved, and the response speed of the interfaces is improved.
For example, data with high access frequency and low effectiveness are given longer effective time in the cache, and when the mobile phone bank accesses the interface, the probability of cache hit is high, so that frequent access to a system database is avoided, and the response speed of the interface is improved.
It should be noted that, fig. 1 is only an optional specific implementation manner of a data caching method provided by the embodiment of the present application, and the method may also include other specific implementation manners, for example, the preset cache time may be directly used as the initial cache time, and for example, the access weight of the interface may be a ratio of the number of calls of the interface in a preset period to an average value of the number of calls of all interfaces in the preset period.
In summary, the data caching method provided in the embodiment of the present application may be summarized as a flow chart of the data caching method shown in fig. 2, and as shown in fig. 2, the method may include S201 to S203.
S201, obtaining the cache time of the interface.
In this embodiment, the buffer time of the interface is the storage time of the data accessed by the calling interface in the buffer.
It should be noted that, at the initial time of the preset period, the buffer time of the interface is the initial buffer time of the interface, optionally, the initial buffer time of the interface may be determined according to the access weight, specifically referring to S104, and the method for obtaining the initial buffer time of the interface may further include other methods, specifically referring to the prior art.
S202, in response to the failure of the cache data, updating the cache time of the interface.
In this embodiment, the cache data is obtained by writing the data accessed by the interface into the cache, and the cache data failure refers to that the cache data is inconsistent with the data, or the retention time of the cache data expires, so that the cache data is removed from the cache.
Optionally, in response to the invalidation of the cache data, the method for updating the cache time of the interface includes various methods, optionally, when the updating of the data triggers the invalidation of the cache data, the cache time of the interface is reduced, specifically, S105 to S107 may be referred to above, optionally, when the saving time of the cache data expires to trigger the invalidation of the cache data, the cache time of the interface is increased, and specifically, S108 to S110 may be referred to above.
It should be noted that, in response to the cache data failure, the method of updating the cache time of the interface is not limited to the methods described in S105 to S107 or S108 to S110, but may include other methods, which are not limited in this application.
And S203, responding to the interface access data, and writing the data into a cache by taking the updated cache time of the interface as the data storage time.
In this embodiment, the updated buffer time of the interface is used as a time tag for calling the data accessed by the interface, and the data is stored in the buffer, where the time tag is the storage time of the data, and specifically, refer to the prior art.
According to the data caching method provided by the embodiment of the application, the caching time of the interface is obtained, the caching time of the interface is the storage time of the data accessed by the calling interface in the cache, the caching time of the interface is updated in response to the invalidation of the caching data, wherein the caching data is obtained by writing the data accessed by the interface into the cache, and the updated caching time of the interface is used as the storage time of the data in response to the accessing of the interface, and the data is written into the cache. It can be understood that the invalidation of the buffered data is at least related to the timeliness of the data, so that it can be seen that the data buffering method provided by the embodiment of the application can adaptively adjust the buffering time of the interface according to the invalidation of the buffered data, so that the buffering time of the interface is related to the timeliness of the data, and the hit rate of the buffered data is improved.
Fig. 3 shows a schematic structural diagram of a data caching apparatus according to an embodiment of the present application, where, as shown in fig. 3, the apparatus may include:
a buffer time determining unit 301, configured to obtain a buffer time of an interface, where the buffer time of the interface is a storage time of data accessed by calling the interface in a buffer;
a cache time updating unit 302, configured to update, in response to a cache data invalidation, the cache time of the interface, where the cache data is obtained by writing the data accessed by the interface into a cache;
and the data caching unit 303 is configured to write the data into a cache in response to the interface accessing the data, with the updated cache time of the interface being a save time of the data.
Optionally, the cache time determining unit is configured to obtain the cache time of the interface, including: the cache time determining unit is specifically configured to:
acquiring a preset access weight of the interface;
and multiplying the preset cache time by the access weight to obtain the cache time of the interface.
Optionally, the cache time determining unit is configured to obtain a preset access weight of the interface, and includes: the cache time determining unit is specifically configured to:
collecting the accumulated access quantity of the interface, wherein the accumulated access quantity is the data access quantity of the interface in a preset period;
calculating an average access amount, wherein the average access amount is an average value of the accumulated access amounts of all interfaces in the period;
and calculating the ratio of the accumulated access quantity to the average access quantity as the access weight of the interface.
Optionally, the cache time updating unit is configured to update the cache time of the interface in response to a cache data failure, including: the cache time updating unit is specifically configured to:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
Optionally, the buffer time updating unit is configured to reduce the buffer time of the interface, and includes: the cache time updating unit is specifically configured to:
reducing the buffer time of the interface by a preset first value to obtain a first buffer time of the interface;
if the first cache time of the interface is not smaller than a preset minimum threshold value, updating the cache time of the interface to the first cache time.
And if the first cache time of the interface is smaller than the minimum threshold value, updating the cache time of the interface to the minimum threshold value.
Optionally, the cache time updating unit is configured to increase the cache time of the interface, and includes: the cache time updating unit is specifically configured to:
increasing the buffer time of the interface by a preset second value to obtain a second buffer time of the interface;
if the second cache time of the interface is not greater than a preset maximum threshold value, updating the cache time of the interface to the second cache time;
and if the second cache time of the interface is greater than the maximum threshold, updating the cache time of the interface to the maximum threshold.
Fig. 4 shows a schematic structural diagram of the data caching device, which may include: at least one processor 401, at least one communication interface 402, at least one memory 403, and at least one communication bus 404;
in the embodiment of the present application, the number of the processor 401, the communication interface 402, the memory 403 and the communication bus 404 is at least one, and the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404;
processor 401 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present application, etc.;
the memory 403 may include a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory), etc., such as at least one magnetic disk memory;
the memory stores a program, and the processor can execute the program stored in the memory to implement the steps of the data caching method provided by the embodiment of the application, as follows:
obtaining the cache time of an interface, wherein the cache time of the interface is the storage time of data accessed by calling the interface in a cache;
in response to cache data invalidation, updating the cache time of the interface, wherein the cache data is obtained by writing the data accessed by the interface into a cache;
and responding to the interface to access the data, and writing the data into a cache by taking the updated cache time of the interface as the storage time of the data.
Optionally, obtaining the buffer time of the interface includes:
acquiring a preset access weight of the interface;
and multiplying the preset cache time by the access weight to obtain the cache time of the interface.
Optionally, acquiring a preset access weight of the interface includes:
collecting the accumulated access quantity of the interface, wherein the accumulated access quantity is the data access quantity of the interface in a preset period;
calculating an average access amount, wherein the average access amount is an average value of the accumulated access amounts of all interfaces in the period;
and calculating the ratio of the accumulated access quantity to the average access quantity as the access weight of the interface.
Optionally, in response to a cache data invalidation, updating the cache time of the interface includes:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
Optionally, reducing the buffering time of the interface includes:
reducing the buffer time of the interface by a preset first value to obtain a first buffer time of the interface;
if the first cache time of the interface is not smaller than a preset minimum threshold value, updating the cache time of the interface to the first cache time.
And if the first cache time of the interface is smaller than the minimum threshold value, updating the cache time of the interface to the minimum threshold value.
Optionally, increasing the buffering time of the interface includes:
increasing the buffer time of the interface by a preset second value to obtain a second buffer time of the interface;
if the second cache time of the interface is not greater than a preset maximum threshold value, updating the cache time of the interface to the second cache time;
and if the second cache time of the interface is greater than the maximum threshold, updating the cache time of the interface to the maximum threshold.
The embodiment of the application also provides a readable storage medium, which can store a computer program suitable for being executed by a processor, and when the computer program is executed by the processor, the steps of the data caching method provided by the embodiment of the application are realized as follows:
obtaining the cache time of an interface, wherein the cache time of the interface is the storage time of data accessed by calling the interface in a cache;
in response to cache data invalidation, updating the cache time of the interface, wherein the cache data is obtained by writing the data accessed by the interface into a cache;
and responding to the interface to access the data, and writing the data into a cache by taking the updated cache time of the interface as the storage time of the data.
Optionally, obtaining the buffer time of the interface includes:
acquiring a preset access weight of the interface;
and multiplying the preset cache time by the access weight to obtain the cache time of the interface.
Optionally, acquiring a preset access weight of the interface includes:
collecting the accumulated access quantity of the interface, wherein the accumulated access quantity is the data access quantity of the interface in a preset period;
calculating an average access amount, wherein the average access amount is an average value of the accumulated access amounts of all interfaces in the period;
and calculating the ratio of the accumulated access quantity to the average access quantity as the access weight of the interface.
Optionally, in response to a cache data invalidation, updating the cache time of the interface includes:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
Optionally, reducing the buffering time of the interface includes:
reducing the buffer time of the interface by a preset first value to obtain a first buffer time of the interface;
if the first cache time of the interface is not smaller than a preset minimum threshold value, updating the cache time of the interface to the first cache time.
And if the first cache time of the interface is smaller than the minimum threshold value, updating the cache time of the interface to the minimum threshold value.
Optionally, increasing the buffering time of the interface includes:
increasing the buffer time of the interface by a preset second value to obtain a second buffer time of the interface;
if the second cache time of the interface is not greater than a preset maximum threshold value, updating the cache time of the interface to the second cache time;
and if the second cache time of the interface is greater than the maximum threshold, updating the cache time of the interface to the maximum threshold.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. A data caching method, comprising:
collecting the accumulated access quantity of an interface, wherein the accumulated access quantity is the data access quantity of the interface in a preset period;
calculating an average access amount, wherein the average access amount is an average value of accumulated access amounts of all interfaces in the period;
calculating the ratio of the accumulated access quantity to the average access quantity as the access weight of the interface;
multiplying the preset buffer time by the access weight to obtain the buffer time of the interface, wherein the buffer time of the interface is the storage time of the data accessed by the interface in the buffer;
in response to cache data invalidation, updating the cache time of the interface, wherein the cache data is obtained by writing the data accessed by the interface into a cache;
and responding to the interface to access the data, and writing the data into a cache by taking the updated cache time of the interface as the storage time of the data.
2. The method of claim 1, wherein the updating the cache time of the interface in response to a cache data failure comprises:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
3. The method of claim 2, wherein said reducing said buffering time of said interface comprises:
reducing the buffer time of the interface by a preset first value to obtain a first buffer time of the interface;
if the first cache time of the interface is not less than a preset minimum threshold value, updating the cache time of the interface to the first cache time;
and if the first cache time of the interface is smaller than the minimum threshold value, updating the cache time of the interface to the minimum threshold value.
4. A method according to claim 3, wherein said increasing said buffering time of said interface comprises:
increasing the buffer time of the interface by a preset second value to obtain a second buffer time of the interface;
if the second cache time of the interface is not greater than a preset maximum threshold value, updating the cache time of the interface to the second cache time;
and if the second cache time of the interface is greater than the maximum threshold, updating the cache time of the interface to the maximum threshold.
5. A data caching apparatus, comprising:
the buffer time determining unit is used for collecting the accumulated access quantity of the interface, wherein the accumulated access quantity is the data access quantity of the interface in a preset period; calculating an average access amount, wherein the average access amount is an average value of accumulated access amounts of all interfaces in the period; calculating the ratio of the accumulated access quantity to the average access quantity as the access weight of the interface; multiplying the preset buffer time by the access weight to obtain the buffer time of the interface, wherein the buffer time of the interface is the storage time of the data accessed by the interface in the buffer;
a cache time updating unit, configured to update, in response to a cache data invalidation, the cache time of the interface, where the cache data is obtained by writing the data accessed by the interface into a cache;
and the data caching unit is used for responding to the data accessed by the interface and writing the data into a cache by taking the updated cache time of the interface as the storage time of the data.
6. The apparatus of claim 5, wherein the cache time updating unit is configured to update the cache time of the interface in response to a cache data failure, comprising: the cache time updating unit is specifically configured to:
reducing the buffering time of the interface in response to an update failure of buffered data, the update failure triggered by an update of the data;
and in response to expiration of the cache data, increasing the cache time of the interface, the expiration being triggered by expiration of a retention time of the data in a cache.
7. A data caching apparatus, comprising: a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the data caching method according to any one of claims 1 to 4.
8. A readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the data caching method according to any one of claims 1-4.
CN202010903867.3A 2020-09-01 2020-09-01 Data caching method, device, equipment and readable storage medium Active CN112035526B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010903867.3A CN112035526B (en) 2020-09-01 2020-09-01 Data caching method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010903867.3A CN112035526B (en) 2020-09-01 2020-09-01 Data caching method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112035526A CN112035526A (en) 2020-12-04
CN112035526B true CN112035526B (en) 2023-09-22

Family

ID=73591634

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010903867.3A Active CN112035526B (en) 2020-09-01 2020-09-01 Data caching method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112035526B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114185905A (en) * 2021-12-06 2022-03-15 蓝信移动(北京)科技有限公司 Cache data updating method, apparatus, device, storage medium, and program

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110489063A (en) * 2019-08-27 2019-11-22 北京奇艺世纪科技有限公司 Cache setting method, device, electronic equipment and the storage medium of expired time
CN110837513A (en) * 2019-11-07 2020-02-25 腾讯科技(深圳)有限公司 Cache updating method, device, server and storage medium
US10657064B1 (en) * 2019-01-31 2020-05-19 Salesforce.com. inc. Extending usages of cached data objects beyond cache expiration periods

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10657064B1 (en) * 2019-01-31 2020-05-19 Salesforce.com. inc. Extending usages of cached data objects beyond cache expiration periods
CN110489063A (en) * 2019-08-27 2019-11-22 北京奇艺世纪科技有限公司 Cache setting method, device, electronic equipment and the storage medium of expired time
CN110837513A (en) * 2019-11-07 2020-02-25 腾讯科技(深圳)有限公司 Cache updating method, device, server and storage medium

Also Published As

Publication number Publication date
CN112035526A (en) 2020-12-04

Similar Documents

Publication Publication Date Title
US9552294B2 (en) Dynamically configuring regions of a main memory in a write-back mode or a write-through mode
US9146956B2 (en) Statistical applications in OLTP environment
CN108897495B (en) Cache updating method, device, cache equipment and storage medium
EP3414665A1 (en) Profiling cache replacement
TWI688859B (en) Memory controller and memory page management method
CN112035526B (en) Data caching method, device, equipment and readable storage medium
CN111880731B (en) Data processing method and device and related components
CN110837480A (en) Processing method and device of cache data, computer storage medium and electronic equipment
CN107133369A (en) A kind of distributed reading shared buffer memory aging method based on the expired keys of redis
CN111221828A (en) Method and terminal for improving consistency of database data and cache data
CN108614847B (en) Data caching method and system
CN107562806B (en) Self-adaptive sensing acceleration method and system of hybrid memory file system
CN111061654B (en) Cache refreshing processing method and device and electronic equipment
CN103209212B (en) Based on the data cache method in the Web network management client of RIA and system
CN113495854A (en) Method and system for implementing or managing cache coherence in a host-device system
CN110716940B (en) Incremental data access system
CN110321298B (en) Time interval determination method and device, electronic equipment and medium
US11269784B1 (en) System and methods for efficient caching in a distributed environment
CN110716887A (en) Hardware cache data loading method supporting write hint
CN112199400A (en) Method and apparatus for data processing
CN115080459A (en) Cache management method and device and computer readable storage medium
CN112214178A (en) Storage system, data reading method and data writing method
CN110658999A (en) Information updating method, device, equipment and computer readable storage medium
CN117149781B (en) Group-associative self-adaptive expansion cache architecture and access processing method thereof
CN116010298B (en) NAND type flash memory address mapping method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant