Cache update method and device
By obtaining and counting the access frequency of cached data, obtaining the target data set and performing cache updates, the problem of being unable to distinguish between hot and non-hot data in the prior art is solved, and the accuracy of cache updates and interface performance stability is improved.
Patent Information
- Application Number
- CN202110013570.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-06
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-01-06
AI Technical Summary
In the existing cache technology, the update is based on full cache data, and it is impossible to distinguish between hot and non-hot data for targeted updates. At the same time, it is determined whether the cached data expires and passive updates are passed based on the request, resulting in large fluctuations in interface performance.
By obtaining the pre-recorded data corresponding to the cache update request, the correspondence between each hash function and the access frequency of the data is characterized, and the access frequency in each data is counted to obtain the target data set (i.e., the hot-spot data set) , and update the cache based on the stored target dataset.
It effectively improves the accuracy of frequency statistics, realizes cache updates based on hotspot data, solves the problem of being unable to distinguish between hotspot and non-hotspot data, and reduces interface performance fluctuations.
Smart Images

Figure CN113779453B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, specifically to the field of data processing technology, and in particular to a cache update method and device. Background Art
[0002] Existing cache update technologies generally update local cache data passively based on time expiration or request access. With the development of Internet technology and the complexity of Internet applications, in order to improve user experience, the backend system has higher and higher requirements on the response time of user requests. In order to significantly improve interface performance, various cache frameworks have been widely applied to various systems.
[0003] There are two commonly used cache update technologies: one is the local cache solution, that is, constructing a cache key according to the request, obtaining data from the local cache, and returning if the data is obtained. If the data cannot be obtained or the data has expired, a remote call is made to obtain the data and the local cache is updated; the other is the distributed cache solution, that is, constructing a cache key according to the request, obtaining data from the distributed cache server, and returning if the data is obtained. If the data cannot be obtained or the data has expired, a remote call is made to obtain the data and the distributed cache is updated. Summary of the invention
[0004] The present application provides a cache update method, apparatus, device and storage medium.
[0005] According to a first aspect of the present application, a cache update method is provided, the method comprising: in response to receiving a cache update request, obtaining each pre-recorded data corresponding to the update request, wherein the data is used to characterize the correspondence between each hash function and the access frequency of the data; performing statistics on each access frequency in each data to obtain a target data set corresponding to all the data, and storing the target data set, wherein the target data set is used to characterize a set of data in the data whose access frequency is greater than a preset value; based on the stored target data set, updating the cache corresponding to the target data set.
[0006] In some embodiments, data is represented by a multi-dimensional bit array, and the multi-dimensional bit array is used to characterize the correspondence between each hash function and the access frequency of the data.
[0007] In some embodiments, the data recording process is as follows: construct a cache key corresponding to the update request; based on the various operation results of the cache key value, record the various access frequencies corresponding to the various operation results, and generate data corresponding to the various access frequencies, wherein each operation result is obtained based on the operation of each hash function on the cache key value.
[0008] In some embodiments, statistics are collected on each access frequency in each data to obtain a target data set corresponding to all the data, and the target data set is stored, including: determining a first access frequency corresponding to each data based on a comparison result of each access frequency in each data; obtaining a target data set corresponding to all comparison results based on a comparison result of each first access frequency with a threshold, and storing the target data set locally.
[0009] In some embodiments, based on a stored target data set, a cache corresponding to the target data set is updated, including: based on the stored target data set, the cache corresponding to the target data set is updated using an update method, wherein the update method is used to characterize a judgment based on a first time on a duration of an update request and / or a storage space of the target data set, and the cache includes: a first cache constructed based on a local cache framework and a second cache constructed based on a distributed cache framework.
[0010] In some embodiments, statistics are collected on each access frequency in each data to obtain a target data set corresponding to all the data, including: based on a preset second time, using a data processing method to convert each access frequency in each data to obtain a target data set corresponding to all the converted data, wherein the data processing method is used to characterize that each access frequency value in each data is halved.
[0011] According to a second aspect of the present application, a cache update device is provided, comprising: an acquisition unit, configured to, in response to receiving a cache update request, acquire each pre-recorded data corresponding to the update request, wherein the data is used to characterize the correspondence between each hash function and the access frequency of the data; a statistical unit, configured to count each access frequency in each data, obtain a target data set corresponding to all the data, and store the target data set, wherein the target data set is used to characterize a set of data in the data whose access frequency is greater than a preset value; a first update unit, configured to update the cache corresponding to the target data set based on the stored target data set.
[0012] In some embodiments, the data in the acquisition unit is represented by a multi-dimensional bit array, and the multi-dimensional bit array is used to characterize the corresponding relationship between each hash function and the access frequency of the data.
[0013] In some embodiments, the data in the acquisition unit is recorded through the following modules: a construction module, configured to construct a cache key corresponding to the update request; a recording module, configured to record the access frequencies corresponding to the various operation results based on the cache key value, and generate data corresponding to the various access frequencies, wherein the various operation results are obtained based on the operation of various hash functions on the cache key value.
[0014] In some embodiments, the statistical unit includes: a first determination module, configured to determine the first access frequency corresponding to each data based on the comparison results of each access frequency in each data; a second determination module, configured to obtain a target data set corresponding to all comparison results based on the comparison results of each first access frequency and a threshold, and store the target data set locally.
[0015] In some embodiments, the first update unit is further configured to update the cache corresponding to the target data set based on the stored target data set using an update method, wherein the update method is used to characterize the judgment of the duration of the update request and / or the storage space of the target data set at the first time, and the cache includes: a first cache built based on a local cache framework and a second cache built based on a distributed cache framework.
[0016] In some embodiments, the statistical unit also includes: a conversion module, which is configured to convert each access frequency in each data based on a preset second time using a data processing method to obtain a target data set corresponding to all converted data, wherein the data processing method is used to characterize the halving of each access frequency value in each data.
[0017] According to the third aspect of the present application, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any implementation manner in the first aspect.
[0018] According to a fourth aspect of the present application, the present application provides a non-transitory computer-readable storage medium storing computer instructions, characterized in that the computer instructions are used to enable a computer to execute a method as described in any implementation manner in the first aspect.
[0019] The technology of the present application adopts the response to receiving a cache update request, obtains each pre-recorded data corresponding to the update request, wherein the data is used to characterize the corresponding relationship between each hash function and the access frequency of the data, and the access frequency of each data is counted to obtain the target data set corresponding to all the data, and the target data set is stored. Based on the stored target data set, the cache corresponding to the target data set is updated, which solves the problem that the existing cache technology is based on the full amount of cache data for updating, and cannot distinguish between hot and non-hot data for targeted updates, and the problem that the cache data is passively updated according to the request to determine whether it is expired, resulting in large fluctuations in interface performance. The use of multiple hash operations to record data access frequencies effectively improves the accuracy of frequency statistics. By counting the access frequencies of each data, the target data set (i.e., the hot data set) is obtained, and a method for cache update based on hot data is implemented.
[0020] 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 application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0022] Figure 1 is a schematic diagram of a first embodiment of a cache update method according to the present application;
[0023] Figure 2 It is a scene graph that can implement the cache update method of the embodiment of the present application;
[0024] Figure 3 is a schematic diagram of a second embodiment of a cache update method according to the present application;
[0025] Figure 4 is a structural diagram of an embodiment of a cache update device according to the present application;
[0026] Figure 5 It is a block diagram of an electronic device used to implement the cache update method of an embodiment of the present application. DETAILED DESCRIPTION
[0027] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0029] Figure 1 A schematic diagram 100 of a first embodiment of a cache update method according to the present application is shown. The cache update method comprises the following steps:
[0030] Step 101: in response to receiving a cache update request, obtaining each pre-recorded data corresponding to the update request.
[0031] In this embodiment, when the execution subject (such as a server) receives a cache update request, it can obtain the pre-recorded data corresponding to the update request from a local or remote device through a wired connection or a wireless connection. The acquisition process can be first obtained from the local device, and if it cannot be obtained, it can be obtained again from the remote device. The data can be used to characterize the corresponding relationship between each hash function and the access frequency of the data, and each hash function is different.
[0032] In some optional implementations of this embodiment, the data recording process is as follows: construct a cache key corresponding to the update request; based on the various operation results of the cache key value, record the various access frequencies corresponding to the various operation results, and generate data corresponding to the various access frequencies, wherein each operation result is obtained based on the operation of each hash function on the cache key value. The Count-Min Sketch bitmap data structure is used to store the data modulo the bitmap capacity of the hash value corresponding to the cache key, and the cache key is not directly stored, thereby reducing the storage volume of cache frequency statistical data. The data access frequency is recorded through a variety of hash operations, which effectively improves the accuracy of frequency statistics.
[0033] To further illustrate, the data uses a two-dimensional array to record the data access frequency, where the horizontal axis represents the array length and the vertical axis represents the number of hash functions. The cache key first passes through the first hash function, then modulo the bit position to get the cache position in the array, and then the position data is added by 1 to get the access frequency of the cache for the first hash function; similarly, the remaining hash functions are calculated in turn and modulo the array length and the access frequency of the cache key is recorded. Multiple modulo and recording of cache access frequency can effectively reduce the problem of inaccurate cache frequency statistics due to hash conflicts. By using a bit array to record data access frequency, the cache key is requested through a hash operation to calculate the array index position where the cache is located, and the position data is recorded by +1. The array uses multiple hash operations and multi-dimensional array records to reduce the hash frequency.
[0034] Step 102: Count the access frequencies of each data to obtain a target data set corresponding to all data, and store the target data set.
[0035] In this embodiment, the execution entity can count the access frequencies of each data obtained in step 101, obtain a target data set corresponding to all data, and store the target data set. The target data set can be used to characterize a set of data in which each access frequency is greater than a preset value. The preset value can be pre-set based on actual business needs, for example, the preset value can be a pre-set threshold for determining whether it is hot data.
[0036] Step 103: Based on the stored target data set, update the cache corresponding to the target data set.
[0037] In this embodiment, the execution subject can update the cache corresponding to the target data set based on the stored target data set. The target data set can be stored locally or in a remote server.
[0038] In some optional implementations of this embodiment, each access frequency in each data is counted to obtain a target data set corresponding to all data, including: based on a preset second time, each access frequency in each data is converted using a data processing method to obtain a target data set corresponding to all converted data, wherein the data processing method is used to characterize the halving of each access frequency value in each data. A timed semi-decay strategy is used to clear non-hotspot cache keys to improve the statistical accuracy of hotspot data, effectively reducing the inaccurate frequency statistics caused by hash conflicts.
[0039] For example, when the amount of cache key data is too large, in order to ensure that the frequency of hash conflicts caused by too much cache key storage in the multidimensional array increases, all data records with bit positions greater than 0 in the multidimensional array are half-decayed at regular intervals, and the data records are halved and rounded up.
[0040] It should be noted that the above cache update technology is a well-known technology that is currently widely studied and applied, and will not be described in detail here.
[0041] Continue to see Figure 2, the cache update method 200 of this embodiment runs in the electronic device 201. When the electronic device 201 receives a cache update request, it obtains the pre-recorded data 202 corresponding to the update request, and then the electronic device 201 counts the access frequencies of each data to obtain the target data set corresponding to all the data, and stores the target data set 203. Finally, the electronic device 201 updates the cache corresponding to the target data set based on the stored target data set 204. Among them, the data is used to characterize the corresponding relationship between each hash function and the access frequency of the data, and the target data set is used to characterize the set of data whose access frequencies in the data are greater than the preset value.
[0042] The cache update method provided by the above-mentioned embodiment of the present application adopts a method of obtaining each pre-recorded data corresponding to the update request in response to receiving a cache update request, wherein the data is used to characterize the corresponding relationship between each hash function and the access frequency of the data, and each access frequency in each data is counted to obtain a target data set corresponding to all data, and the target data set is stored. Based on the stored target data set, the cache corresponding to the target data set is updated, which solves the problem that the existing cache technology is based on the full amount of cache data for updating, and cannot distinguish between hotspot and non-hotspot data for targeted updates, and the problem that the cache data is passively updated according to the request to determine whether it is expired, resulting in large fluctuations in interface performance. The use of multiple hash operations to record data access frequencies effectively improves the accuracy of frequency statistics. By analyzing and counting each access frequency in each data, the target data set (i.e., hotspot data set) is obtained, and a method for cache update based on hotspot data is implemented.
[0043] Further references Figure 3 , which shows a schematic diagram 300 of a second embodiment of a cache update method. The process of the method includes the following steps:
[0044] Step 301: in response to receiving a cache update request, obtaining each pre-recorded data corresponding to the update request.
[0045] In this embodiment, when the execution subject receives a cache update request, it can obtain the pre-recorded data corresponding to the update request from the local or remote device through a wired connection or a wireless connection. The data is represented by a multi-dimensional bit array, and the multi-dimensional bit array is used to characterize the corresponding relationship between each hash function and the access frequency of the data, and each hash function is different.
[0046] Step 302: Determine a first access frequency corresponding to each data based on the comparison result of each access frequency in each data.
[0047] In this embodiment, the execution entity may compare the access frequencies of each data obtained in step 301 to obtain the minimum access frequency after comparison as the first access frequency corresponding to each data.
[0048] Step 303: According to the comparison result between each first access frequency and the threshold, a target data set corresponding to all the comparison results is obtained, and the target data set is stored locally.
[0049] In this embodiment, the execution subject can compare each first access frequency with the threshold, and according to the comparison result, take the data corresponding to each first access frequency greater than the threshold as the target data, obtain the target data set corresponding to all the comparison results, and store the target data set locally for subsequent local call. The threshold can represent the minimum value of the access frequency as the hot data, and the threshold can be pre-set based on various requirements.
[0050] Step 304: Based on the stored target data set, the cache corresponding to the target data set is updated using an update method.
[0051] In this embodiment, the execution subject can update the cache corresponding to the target data set using an update method based on the stored target data set. The update method is used to characterize the judgment of the duration of the update request and / or the storage space of the target data set according to the first time, and the cache includes: a first cache built based on a local cache framework and a second cache built based on a distributed cache framework. The first time is preset.
[0052] from Figure 3 It can be seen that Figure 1Compared with the corresponding embodiment, the schematic diagram 300 of the cache update method in this embodiment uses multiple hash operations of multi-dimensional bit arrays to record data access frequencies. Based on the advantage of high bit operation efficiency, the cache key is located at the multi-dimensional array position after hash operation. Only the request frequency is stored without storing the request cache key, which greatly saves storage space, effectively improves the accuracy of frequency statistics, and reduces the memory consumption of the full cache frequency. The first access frequency corresponding to each data is determined based on the comparison results of each access frequency in each data. According to the comparison results of each first access frequency and the threshold, the target data set corresponding to all comparison results is obtained, and the target data set is stored locally. Based on the stored target data set, the cache corresponding to the target data set is updated using an update method. The update method is used to characterize the duration of the update request and / or the storage space of the target data set according to the first time. The cache includes: a first cache built based on a local cache framework and a second cache built based on a distributed cache framework. The cached hotspot data is pre-updated according to the hotspot data access frequency, rather than passively updated, to prevent performance problems caused by hotspot data expiration. It implements data access frequency statistics based on multi-dimensional bit array algorithms, statistics on hot data, and asynchronously pre-updates local cache and distributed cache based on the hot data cache expiration time to avoid performance fluctuations caused by cache penetration after the hot data cache expires.
[0053] Further references Figure 4 , as a response to the above Figures 1 to 3 The present application provides an embodiment of a cache update device, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0054] like Figure 4 As shown, the cache update device 400 of this embodiment includes: an acquisition unit 401, a statistics unit 402 and a first update unit 403, wherein the acquisition unit is configured to, in response to receiving a cache update request, acquire each pre-recorded data corresponding to the update request, wherein the data is used to characterize the correspondence between each hash function and the access frequency of the data; the statistics unit is configured to count each access frequency in each data, obtain a target data set corresponding to all the data, and store the target data set, wherein the target data set is used to characterize a set of data in the data whose access frequency is greater than a preset value; the first update unit is configured to update the cache corresponding to the target data set based on the stored target data set.
[0055] In this embodiment, the specific processing of the acquisition unit 401, the statistical unit 402 and the first updating unit 403 of the cache updating device 400 and the technical effects thereof can be referred to in Figure 1 The relevant descriptions of steps 101 to 103 in the corresponding embodiment are not repeated here.
[0056] In some optional implementations of this embodiment, the data in the acquisition unit is represented by a multi-dimensional bit array, and the multi-dimensional bit array is used to characterize the corresponding relationship between each hash function and the access frequency of the data.
[0057] In some optional implementations of this embodiment, the data in the acquisition unit is recorded through the following modules: a construction module, configured to construct a cache key corresponding to the update request; a recording module, configured to record the access frequencies corresponding to the various operation results based on the cache key value, and generate data corresponding to the various access frequencies, wherein the various operation results are obtained based on the operation of various hash functions on the cache key value.
[0058] In some optional implementations of this embodiment, the statistical unit includes: a first determination module, configured to determine the first access frequency corresponding to each data based on the comparison results of each access frequency in each data; a second determination module, configured to obtain a target data set corresponding to all comparison results based on the comparison results of each first access frequency and a threshold, and store the target data set locally.
[0059] In some optional implementations of this embodiment, the first update unit is further configured to update the cache corresponding to the target data set based on the stored target data set using an update method, wherein the update method is used to characterize the judgment of the duration of the update request and / or the storage space of the target data set at the first time, and the cache includes: a first cache built based on a local cache framework and a second cache built based on a distributed cache framework.
[0060] In some optional implementations of this embodiment, the statistical unit also includes: a conversion module, which is configured to convert each access frequency in each data based on a preset second time using a data processing method to obtain a target data set corresponding to all converted data, wherein the data processing method is used to characterize the halving of each access frequency value in each data.
[0061] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0062] like Figure 5, is a block diagram of an electronic device according to a cache update method according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, 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 application described and / or required herein.
[0063] like Figure 5 As shown, the electronic device includes: one or more processors 501, a memory 502, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 501 is taken as an example.
[0064] The memory 502 is a non-transient computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable at least one processor to execute the cache update method provided in the present application. The non-transient computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to execute the cache update method provided in the present application.
[0065] The memory 502 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the cache update method in the embodiment of the present application (for example, the attached Figure 4 The processor 501 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 502, that is, the cache update method in the above method embodiment is implemented.
[0066] The memory 502 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created according to the use of the cache update electronic device, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 502 may optionally include a memory remotely arranged relative to the processor 501, and these remote memories may be connected to the cache update electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0067] The electronic device of the cache update method may further include: an input device 503 and an output device 504. The processor 501, the memory 502, the input device 503 and the output device 504 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0068] The input device 503 can receive input digital or character information, and generate key signal input related to the user settings and function control of the cache update electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 504 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.
[0069] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0070] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (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.
[0071] 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).
[0072] 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.
[0073] 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.
[0074] The technical solution according to the embodiment of the present application adopts a method of obtaining each pre-recorded data corresponding to the update request in response to receiving a cache update request, wherein the data is used to characterize the corresponding relationship between each hash function and the access frequency of the data, and the access frequency of each data is counted to obtain the target data set corresponding to all the data, and the target data set is stored. Based on the stored target data set, the cache corresponding to the target data set is updated, which solves the problem that the existing cache technology is based on the full amount of cache data for updating, and cannot distinguish between hotspot and non-hotspot data for targeted updates, and the problem that the cache data is passively updated according to the request to determine whether it is expired, resulting in large fluctuations in interface performance. The use of multiple hash operations to record data access frequencies effectively improves the accuracy of frequency statistics. By analyzing and counting the access frequencies of each data, the target data set (i.e., the hotspot data set) is obtained, and a method for cache update based on hotspot data is implemented.
[0075] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0076] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A cache update method, comprising: In response to receiving a cache update request, obtaining each pre-recorded data corresponding to the update request, wherein the data is used to characterize the corresponding relationship between each hash function and the access frequency of the data; Counting the access frequencies of each of the data to obtain a target data set corresponding to all the data, and storing the target data set, wherein the target data set is used to characterize a set of data whose access frequencies are greater than a preset value, and the preset value is a preset threshold for determining whether it is hot data; Based on the stored target data set, a cache corresponding to the target data set is updated.
2. The method according to claim 1, wherein: The data is represented by a multi-dimensional bit array, and the multi-dimensional bit array is used to characterize the corresponding relationship between each hash function and the access frequency of the data.
3. The method according to claim 2, wherein: The data recording process is as follows: Constructing a cache key corresponding to the update request; Based on each operation result of the cache key value, each access frequency corresponding to the each operation result is recorded, and data corresponding to the each access frequency is generated, wherein each operation result is obtained based on the operation of each hash function on the cache key value.
4. The method according to claim 1, wherein: The counting of the access frequencies of each of the data to obtain a target data set corresponding to all the data and storing the target data set includes: Determine a first access frequency corresponding to each of the data based on a comparison result of each of the access frequencies in the data; According to the comparison result between each of the first access frequencies and the threshold, the target data set corresponding to all the comparison results is obtained, and the target data set is stored locally.
5. The method according to claim 1, wherein: The updating of the cache corresponding to the target data set based on the stored target data set includes: Based on the stored target data set, the cache corresponding to the target data set is updated using an update method, wherein the update method is used to characterize the judgment of the duration of the update request and / or the storage space of the target data set at a first time, and the cache includes: a first cache built based on a local cache framework and a second cache built based on a distributed cache framework.
6. The method according to claim 1, wherein: The statistics of the access frequencies of each of the data are collected to obtain a target data set corresponding to all the data, and further includes: Based on a preset second time, a data processing method is used to convert each of the access frequencies in the data to obtain a target data set corresponding to all the converted data, wherein the data processing method is used to characterize that each of the access frequency values in each of the data is halved.
7. A cache updating device, comprising: an acquisition unit, configured to, in response to receiving a cache update request, acquire each pre-recorded data corresponding to the update request, wherein the data is used to characterize a corresponding relationship between each hash function and an access frequency of the data; a statistical unit configured to perform statistics on each of the access frequencies in each of the data, obtain a target data set corresponding to all of the data, and store the target data set, wherein the target data set is used to represent a set of the data in which each of the access frequencies in the data is greater than a preset value; The first updating unit is configured to update the cache corresponding to the target data set based on the stored target data set.
8. The device according to claim 7, wherein: The data in the acquisition unit is represented by a multi-dimensional bit array, and the multi-dimensional bit array is used to characterize the corresponding relationship between each hash function and the access frequency of the data.
9. The device according to claim 8, wherein: The data in the acquisition unit is recorded and obtained through the following modules: A construction module, configured to construct a cache key corresponding to the update request; The recording module is configured to record the access frequencies corresponding to the various operation results of the cache key value based on the various operation results, and generate data corresponding to the various access frequencies, wherein the various operation results are obtained based on the operation of the various hash functions on the cache key value.
10. The device according to claim 7, wherein: The statistical unit comprises: A first determining module is configured to determine a first access frequency corresponding to each of the data based on a comparison result of each of the access frequencies in each of the data; The second determination module is configured to obtain the target data set corresponding to all the comparison results according to the comparison result between each of the first access frequencies and the threshold, and store the target data set locally.
11. The device according to claim 7, wherein: The first update unit is further configured to update the cache corresponding to the target data set based on the stored target data set using an update method, wherein the update method is used to characterize the judgment of the duration of the update request and / or the storage space of the target data set at a first time, and the cache includes: a first cache built based on a local cache framework and a second cache built based on a distributed cache framework.
12. The device according to claim 7, wherein: The statistical unit also includes: The conversion module is configured to convert each of the access frequencies in each of the data based on a preset second time using a data processing method to obtain a target data set corresponding to all the converted data, wherein the data processing method is used to characterize the halving of each of the access frequency values in each of the data.
13. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.