CN117193670A - Method and device for clearing cache, storage medium and electronic equipment - Google Patents

Method and device for clearing cache, storage medium and electronic equipment Download PDF

Info

Publication number
CN117193670A
CN117193670A CN202311464151.8A CN202311464151A CN117193670A CN 117193670 A CN117193670 A CN 117193670A CN 202311464151 A CN202311464151 A CN 202311464151A CN 117193670 A CN117193670 A CN 117193670A
Authority
CN
China
Prior art keywords
target data
data
cache
clearing
database
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.)
Granted
Application number
CN202311464151.8A
Other languages
Chinese (zh)
Other versions
CN117193670B (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.)
Zhejiang Lab
Original Assignee
Zhejiang Lab
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 Zhejiang Lab filed Critical Zhejiang Lab
Priority to CN202311464151.8A priority Critical patent/CN117193670B/en
Publication of CN117193670A publication Critical patent/CN117193670A/en
Application granted granted Critical
Publication of CN117193670B publication Critical patent/CN117193670B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The specification discloses a method, a device, a storage medium and an electronic device for clearing a cache, which specifically include: and according to the received data processing request, determining corresponding target data in the database, and creating annotation information for the target data. The annotation information includes table information in the database with the target data, key information in the distributed cache, and purge mode information. A cache flush task for the target data is created from the annotation information. And then, monitoring whether the target data in the database is changed or not through a monitor, and clearing the target data cached in the distributed cache through a cache clearing task for the target data confirmed to be changed. The method can effectively avoid the occurrence of dirty data in the distributed cache when a plurality of applications execute tasks, and further avoid the occurrence of errors or the situation that the tasks cannot be executed correctly in the task execution process when the applications use the dirty data to execute the tasks.

Description

Method and device for clearing cache, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for clearing a cache, a storage medium, and an electronic device.
Background
In the field of computer storage, the distributed cache can effectively improve the reading speed of instructions and data when a plurality of applications execute tasks.
Although the plurality of applications can bring high-speed data reading convenience through the distributed cache when executing a plurality of tasks in parallel, the plurality of applications may cause the data information in the distributed cache to be different from the changed data information in the database when respectively changing the data information of the database, so that legacy cache data, i.e. dirty data, appears in the distributed cache. The occurrence of dirty data causes negative influence on the execution process of the subsequent task, so that when the application executes the subsequent task, the task execution is wrong, or the application cannot continue to execute the next task and other abnormal conditions are caused.
Therefore, it is important to eliminate the negative effects of dirty data left in the distributed cache when the application performs tasks.
Disclosure of Invention
The present disclosure provides a method for clearing a cache, so as to partially solve the above-mentioned problems in the prior art.
The technical scheme adopted in the specification is as follows:
the specification provides a method for clearing a cache, which comprises the following steps:
receiving a data processing request;
determining target data which needs to be called from a database according to the data processing request;
creating annotation information for the target data, wherein the annotation information at least comprises table information of a table storing the target data in a database, and key information of the target data in a distributed cache;
according to the target data, carrying out data processing, and caching the target data in the distributed cache;
and when the change of the target data in the database is monitored by a deployed monitor, clearing the target data cached in the distributed cache based on the annotation information.
Optionally, the data type of the data cached in the distributed cache includes a first type and a second type, wherein the service priority of the data of the first type is higher than that of the data of the second type;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises a synchronous clearing mode;
creating annotation information for the target data, specifically including:
Determining a data type of the target data;
if the data type of the target data is determined to be the first type, annotation information containing mode information of the synchronous clearing mode is created for the target data.
Optionally, the data type of the data cached in the distributed cache includes a first type and a second type, wherein the service priority of the data of the first type is higher than that of the data of the second type;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises an asynchronous clearing mode;
creating annotation information for the target data, specifically including:
determining a data type of the target data;
if the data type of the target data is determined to be the second type, annotation information containing mode information of the asynchronous clear mode is created for the target data.
Optionally, when the target data in the database is monitored to be changed by the deployed monitor, based on the annotation information, the target data cached in the distributed cache is cleared, which specifically includes:
when the target data in the database is monitored to be changed through a locally deployed monitor, a first clearing instruction is generated according to the annotation information, so that the target data in the distributed cache is cleared according to the first clearing instruction.
Optionally, when the target data in the database is monitored to be changed by the deployed monitor, based on the annotation information, the target data cached in the distributed cache is cleared, which specifically includes:
creating a cache clearing task for the target data according to the annotation information;
and sending the cache clearing task to a distributed system based on distributed caches, so that the distributed system generates a second clearing instruction when a monitor deployed in the distributed system monitors that the target data in the database is changed, and the cache clearing task is executed through the second clearing instruction so as to clear the target data cached in the distributed caches.
Optionally, the cache cleaning task is sent to a distributed system on which the distributed cache is based, so that when the distributed system monitors that the target data in the database is changed based on a monitor deployed in the distributed system, a second cleaning instruction is generated, and the cache cleaning task is executed through the second cleaning instruction, so as to clean the target data cached in the distributed cache, which specifically includes:
And sending the cache clearing task to a distributed system on which the distributed cache is based, so that the distributed system judges whether a preset task queue stores a clearing task corresponding to the target data, if so, when responding to the monitor to monitor the change of the target data in the database, clearing the target data cached in the distributed cache according to the clearing task corresponding to the target data stored in the task queue or the cache clearing task, otherwise, adding the cache clearing task into the task queue, and executing the task contained in the task queue when responding to the monitor to monitor the change of the target data in the database, so as to clear the target data cached in the distributed cache.
The present specification provides an apparatus for clearing a cache, including:
the receiving module is used for receiving the data processing request;
the determining module is used for determining target data which needs to be called from a database according to the data processing request;
the creating module is used for creating annotation information aiming at the target data, wherein the annotation information at least comprises table information of a table for storing the target data in a database, and key information of the target data in a distributed cache;
The caching module is used for carrying out data processing according to the target data and caching the target data in the distributed cache;
and the clearing module is used for clearing the target data cached in the distributed cache based on the annotation information when the deployed monitor monitors that the target data in the database is changed.
Optionally, the data type of the data cached in the distributed cache includes a first type and a second type, wherein the service priority of the data of the first type is higher than that of the data of the second type;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises a synchronous clearing mode;
the creation module is specifically configured to determine a data type of the target data; if the data type of the target data is determined to be the first type, annotation information containing mode information of the synchronous clearing mode is created for the target data.
The present specification provides a computer readable storage medium storing a computer program which when executed by a processor implements the above method of cache removal.
The present specification provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above method of cache removal when executing the program.
The above-mentioned at least one technical scheme that this specification adopted can reach following beneficial effect:
as can be seen from the above-described method, in the method of clearing a cache provided in the present specification, target data corresponding to a data processing request in a database is determined according to the received data processing request, and annotation information for the target data is created. The annotation information comprises table information of target data in a database, key information in a distributed cache and clearing mode information. And then, the corresponding target data is cached in the distributed cache, and a cache clearing task for the target data is created according to the annotation information. And then, monitoring whether the target data in the database is changed or not through a deployed monitor, and clearing the target data cached in the distributed cache for the target data confirmed to be changed.
From the above, it can be seen that, by the method for clearing the cache provided by the present disclosure, the changing conditions of various data in the database can be monitored in real time, so that the data corresponding to the changed data in the database in the distributed cache can be cleared in time, thereby effectively avoiding the occurrence of the situation that the dirty data is left in the distributed cache when a plurality of applications execute a plurality of same or different tasks, and further avoiding the situation that the tasks cannot be executed correctly or in error in the task execution process when the applications execute the corresponding tasks according to the dirty data. And the processing efficiency of the application for business processing based on the data in the distributed cache and the accuracy of the application for completing the corresponding tasks are also improved to a certain extent.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification, illustrate and explain the exemplary embodiments of the present specification and their description, are not intended to limit the specification unduly. In the drawings:
FIG. 1 is a flow chart of a method for clearing a cache provided in the present specification;
FIG. 2 is a schematic diagram of a distributed system provided herein;
FIG. 3 is a schematic diagram illustrating a process of a multi-service server for cleaning distributed caches according to the present disclosure;
FIG. 4 is a schematic diagram of an apparatus for cache removal provided in the present specification;
fig. 5 is a schematic structural diagram of an electronic device corresponding to fig. 1 provided in the present specification.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present specification more apparent, the technical solutions of the present specification will be clearly and completely described below with reference to specific embodiments of the present specification and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present specification. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
The following describes in detail the technical solutions provided by the embodiments of the present specification with reference to the accompanying drawings.
Fig. 1 is a flow chart of a method for clearing a cache, provided in the present specification, including the following steps:
s101: a data processing request is received.
S102: and determining target data which needs to be called from a database according to the data processing request.
With the continuous development of technology, the scenario of data transmission between multiple applications and the same database is not rare at present, and the data reading rate of multiple applications when executing corresponding tasks can be greatly improved due to the occurrence of distributed caching. However, the distributed cache brings convenience to high-speed data reading, and dirty data which is different from that in the database exists in the distributed cache due to the concurrent change operation of a plurality of applications, so that the applications execute corresponding tasks by using wrong data, and wrong task execution results or other abnormal conditions are generated. Therefore, how to accurately and completely eliminate the negative effect of the dirty data in the distributed cache on the task execution process of the application program is a problem to be solved.
For this reason, the present specification provides a method for clearing a cache, where the execution body adopted in the method provided in the present specification may be a server, or may be a terminal device such as a desktop computer, a notebook computer, or the like. In addition, the execution subject of the present specification may be a subject in the form of software, such as a client installed in a server. For convenience of explanation, the method for clearing the cache provided will be explained below with the server as the execution subject.
The servers can be servers of all service parties, so that in the whole distributed system, the servers can be regarded as all nodes, each node corresponds to a corresponding distributed cache or a distributed cache shared by a plurality of nodes, and the distribution of the distributed caches can be balanced according to specific requirements and system conditions. Then, during the process of executing the service, a node (i.e. a server) may acquire service data from a database in the distributed system, and in order to improve the multiplexing efficiency of the service data, the service data may be cached in a distributed cache corresponding to the node.
Based on the above, the server applying the method for clearing the cache provided by the specification can clear the corresponding data in the distributed cache of the changed data in the database in time based on the changing conditions of various data in the database.
The specific situation that the server changes the data of the database can be determined according to the actual scene, for example, the servers of a plurality of service parties share the service data of the same user, and when the user changes the service data in the database through one of the servers of the plurality of service parties, the server can clear the service data before the change in the distributed cache, so that other servers cannot acquire the unchanged service data from the distributed cache, and only the changed service data can be obtained from the database; for another example, in video sharing software or websites, it is common to refer to a distributed cache of various video file data, and when a video developer or a server changes or deletes the video file data, the server clears old video file data in the distributed cache, so that if a user wants to acquire the corresponding video file data again, the user can only send an acquisition request of the corresponding data to the database.
In the present specification, the server determines, from the database, target data corresponding to the received data processing request.
The data processing request mentioned above may be generated by a data processing operation performed by a user on a service terminal (e.g., a client, a web page, etc.) of a service party to which the server belongs, and the server may determine the target data in the database according to the received data processing request. Of course, the data processing request may also be that the server generates a corresponding data processing request according to a related operation instruction sent by the user to the server through the service terminal, and determines the target data from the database according to the data processing request.
S103: and creating annotation information aiming at the target data, wherein the annotation information at least comprises table information of a table storing the target data in a database, and key information of the target data in the distributed cache.
In this specification, the server may create annotation information corresponding to target data for the target data determined according to the data processing request. The annotation information of the target data may include: the method comprises the steps of table information of a data table where target data are located in a database, key information of the target data in a distributed cache, and clearing mode information when the target data clear the distributed cache.
Wherein table information of the target data may be used to indicate in which data table in the database the target data is specific and the specific location of the target data in the data table. The key information of the target data in the distributed cache can be used for identifying the target data in the distributed cache, so that the server can determine cache data corresponding to the target data according to the key information of the target data in the distributed cache, and subsequent cache clearing work can be performed. The clearing mode information of the target data can be used for representing different modes adopted by the target data when the distributed cache is cleared, and the type of the cache data of the target data in the distributed cache can be reflected. The types of the above-mentioned cache data are classified into two types: the method comprises the steps of a first type and a second type, wherein the clearing mode of target data corresponding to the first type of cache data is synchronous clearing mode, and the clearing mode of target data corresponding to the second type of cache data is asynchronous clearing mode.
It should be noted that, the main difference between the first type of cache data and the second type of cache data is that the service priority of the first type of data is higher than that of the second type of data, that is, when the data in the distributed cache is cleared later, if the target data corresponding to the first type of data is changed in the database, the corresponding cache data in the distributed cache needs to be cleared immediately after the target data is changed, that is, the data in the first type needs to be cleared synchronously. For example, in the scene of modifying the commodity price of the online shopping platform, in order to ensure the consistency of the commodity price obtained by the customer and the commodity price after modification in the database, the old commodity price in the Ma Duifen distributed cache needs to be cleared after the commodity price is changed in the database, so that the problem that the subsequent customer proposes objection to the change of the commodity price in the payment link is avoided.
If the target data corresponding to the second type of data is changed in the database, the cache data corresponding to the target data before the change in the distributed cache is not strictly required to be cleared in time, namely the second type of data is cleared asynchronously. For example, in the news field, news authors often perform operations such as updating news content in a news display interface at intervals, after related content in a database changes, the content of the news display interface does not need to change strictly without any time gap, and a user who can delay updating the news content or browse news manually refreshes a display page, etc.
S104: and carrying out data processing according to the target data, and caching the target data in the distributed cache.
In the present specification, after determining target data from a database according to a data processing request and creating annotation information of the completed target data, the server performs corresponding processing on the target data, and stores the corresponding target data into a distributed cache.
It should be noted that, the main purpose of storing the target data into the distributed cache is that when the user initiates the data processing operation or the related operation instruction of the corresponding target data through the service terminal again, the server may perform fast reading and transmission of the corresponding target data through the distributed cache. Compared with the method that after each time of user initiates related operation, the server acquires the corresponding target data from the database again, the method is quicker, the data reading rate of the server is greatly improved, and the data transmission pressure of the whole network system when a plurality of servers of different service parties share the same database is reduced.
S105: and when the change of the target data in the database is monitored by a deployed monitor, clearing the target data cached in the distributed cache based on the annotation information.
In the present specification, after annotation information of target data is created, the server caches the target data in the distributed cache, and monitors the target data of the database through deployed monitors. When the changed target data exists, the cache data of the target data in the distributed cache is cleared according to the annotation information of the target data.
The server can clear the cache data in the distributed cache in different modes according to the clearing mode information in the annotation information of the target data. Firstly, regarding the synchronous clearing mode, for each server of different service parties, a server of a certain service party can adopt a locally deployed monitor in the server to monitor whether the server updates or deletes target data in a database, if the monitor monitors that the server updates or deletes the target data, the monitor generates a corresponding first clearing instruction according to annotation information of the target data in the synchronous clearing mode, and then the server clears cache data corresponding to the target data in the distributed cache according to the first clearing instruction, thereby realizing synchronous clearing of the distributed cache.
In short, after the server updates or deletes the data in the database, the server will immediately and automatically clear the corresponding old target data in the distributed cache after the target data is changed, thereby effectively avoiding the occurrence of dirty data, and avoiding the occurrence of situations such as execution by using the dirty data when the server executes subsequent business tasks.
It should be noted that, in the above method for cleaning distributed cache of target data with synchronous cleaning mode, the listener is deployed in a server of a certain service party, and the listener only listens to the update and deletion operations of the server of the service party to the database, and cannot perceive the change of the server of other service parties to the data in the database. Therefore, the method does not affect the operation of clearing the distributed cache of the server of other service parties, that is, the synchronous clearing mode is mainly aimed at the distributed cache clearing mode used after the server itself changes the data in the database. The listener deployed in the server may adopt a functional module capable of implementing listening to the data modification instruction, such as an SQL Interceptor (SQL Interceptor) commonly used in the database field, and the description does not specifically limit the listener deployed in the server.
Further, regarding the asynchronous flush mode, the server may generate a cache flush task for each target data according to the annotation information of each target data, and send the cache flush task for each target data to the distributed system. The distributed system is also provided with a monitor, the monitor in the distributed system can monitor the target data in the database in real time, and when the monitor monitors that the target data in the database is changed, the distributed system can generate a second clearing instruction corresponding to the target data, and execute a cache clearing task corresponding to the target data according to the second clearing instruction so as to clear the cache data of the target data in the distributed cache, namely asynchronously clear the cache data of the target data.
The distributed system may include three modules, namely a database monitoring module, a task management module, and a distributed cache cleaning module, as shown in fig. 2.
Fig. 2 is a schematic diagram of a distributed system provided in the present specification.
As shown in fig. 2, the database monitoring module of the distributed system is a monitor set in the distributed system, and may be used for monitoring changed target data in the database, and the data monitoring module may be implemented by adopting a technology with a data change capturing function, such as a change data capturing CDC (Change Data Capture) technology commonly used in the database field, which is not limited in the manner how the distributed system monitors the data change in the database in this specification.
The task management module of the distributed system is used for judging whether the acquired cache clearing task is stored in a preset task queue, if the acquired cache clearing task exists in the preset task queue, when the target data in the database is monitored to be changed in response to the database monitoring module, the clearing task or the cache clearing task corresponding to the stored target data is executed through the distributed cache clearing module in the distributed system, so that the cache data of the target data in the distributed cache is cleared. If the obtained cache clearing task does not exist in the preset task queue, the cache clearing task of the target data is added into the task queue, and when the response database monitoring module monitors that the target data in the database is changed, the corresponding task is executed, so that the cache data of the target data in the distributed cache is cleared.
It should be noted that, no matter the clearing mode information in the annotation information of the target data indicates the synchronous clearing mode or the asynchronous clearing mode, the server generates a cache clearing task corresponding to the target data and sends the cache clearing task to the distributed system, that is, the distributed system can perform an asynchronous clearing operation on the target data which has been subjected to synchronous clearing after the server changes the database. Because the data can be cleared after the database is monitored to be changed through the distributed system, compared with the cache clearing process after the target data is directly changed by the server, the delay is higher, so that the cache clearing operation can be carried out on the target data with the synchronous clearing mode twice, and the accuracy of the distributed cache clearing process of the target data with strict time limit requirements on the distributed cache clearing is effectively improved.
In summary, in order to more clearly describe the method for cleaning the cache provided in the present specification, a process of cleaning the distributed cache by using a multi-service server will be described below, as shown in fig. 3.
Fig. 3 is a schematic diagram of a process of cleaning a distributed cache by a multi-service server provided in the present specification.
As shown in fig. 3, the first service side server, the second service side server, and the database terminal server may change data in the database, and each service side server may generate a corresponding cache cleaning task according to annotation information of each target data, and send the cache cleaning task to the distributed system. When monitors arranged in the servers monitor that the servers change or delete the target data with the synchronous mode, the corresponding servers can directly clear the target data in the distributed cache so as to complete synchronous cache clearing operation.
When the database monitoring module in the distributed cache monitors that the data in the database is changed, a corresponding cache clearing task is executed, and target data in the distributed cache is cleared to complete asynchronous cache clearing operation. After the distributed system acquires the cache cleaning task sent by each server, the cache cleaning task can be compared with task queues existing in a task management module in the distributed system, and the task queues can be used for representing each cache cleaning task corresponding to each server. The task management module further comprises a cache cleaning task pool, wherein the cache cleaning task pool is mainly used for managing cache cleaning tasks sent by all servers, and the cache cleaning task pool records which servers each cache cleaning task is initiated by. Therefore, the task queue and the cache-cleaning task pool are mainly different in that the task queue is mainly used for reflecting which tasks are initiated by each server, and the cache-cleaning task pool is used for reflecting which servers are initiated by each task.
The task management module may update the task queue according to the cache cleaning task sent by each server, and update the cache cleaning task pool according to the updated task queue. The method comprises the specific operation that if a newly added cache clearing task exists in an updated task queue in a cache clearing task pool and the initiated servers are different, information of the server corresponding to the cache clearing task in the task queue is added into a server initiated list of the cache clearing task in the task pool; if the buffer clearing task pool does not exist the buffer clearing task newly added in the updated task queue, the buffer clearing task is added into the buffer clearing task pool.
And if the cache cleaning task initiated by a deleted server in the updated task queue exists in the cache cleaning task pool, deleting the server information corresponding to the server initiating list of the cache cleaning task in the cache task pool, and eliminating the cache cleaning task from the cache task pool when all initiating servers in the server initiating list of the cache cleaning task are deleted.
From the above, it can be seen that, the method for clearing the cache provided in the present disclosure may monitor, in real time, the changing conditions of various data in the database, so as to clear the data corresponding to the changed data in the database in the distributed cache in time, and may also use different clearing modes according to the target data having different requirements on the time limitation of clearing the cache. The method effectively avoids the situation that the server generates left dirty data in the distributed cache when executing a plurality of different business tasks, and further avoids the situation that the task cannot be executed correctly or errors occur in the task execution process when executing the corresponding task according to the dirty data, and improves the processing efficiency of business processing of the servers of different business parties based on the data in the distributed cache to a certain extent, and the accuracy of the servers completing the corresponding business tasks.
The foregoing is a method implemented by one or more embodiments of the present disclosure, and based on the same concept, the present disclosure further provides a corresponding apparatus for clearing a cache, as shown in fig. 4.
Fig. 4 is a schematic diagram of an apparatus for clearing a cache provided in the present specification, including:
a receiving module 401, configured to receive a data processing request;
a determining module 402, configured to determine, according to the data processing request, target data that needs to be called from a database;
a creating module 403, configured to create annotation information for the target data, where the annotation information includes at least table information of a table storing the target data in a database, and key information of the target data in a distributed cache;
the caching module 404 is configured to perform data processing according to the target data, and cache the target data in the distributed cache;
and the clearing module 405 is configured to clear the target data cached in the distributed cache based on the annotation information when the deployed listener listens to the target data in the database is changed.
Optionally, the data type of the data cached in the distributed cache includes a first type and a second type, wherein the service priority of the data of the first type is higher than that of the data of the second type;
The annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises a synchronous clearing mode;
the creation module 403 is specifically configured to determine a data type of the target data; if the data type of the target data is determined to be the first type, annotation information containing mode information of the synchronous clearing mode is created for the target data.
Optionally, the data type of the data cached in the distributed cache includes a first type and a second type, wherein the service priority of the data of the first type is higher than that of the data of the second type;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises an asynchronous clearing mode;
the creation module 403 is specifically configured to determine a data type of the target data; if the data type of the target data is determined to be the second type, annotation information containing mode information of the asynchronous clear mode is created for the target data.
Optionally, the purging module 405 is specifically configured to generate, when the target data in the database is monitored to be changed by a locally deployed monitor, a first purging instruction according to the annotation information, so as to purge the target data in the distributed cache according to the first purging instruction.
Optionally, the clearing module 405 is specifically configured to create a cache clearing task for the target data according to the annotation information; and sending the cache clearing task to a distributed system based on distributed caches, so that the distributed system generates a second clearing instruction when a monitor deployed in the distributed system monitors that the target data in the database is changed, and the cache clearing task is executed through the second clearing instruction so as to clear the target data cached in the distributed caches.
Optionally, the clearing module 405 is specifically configured to send the cache clearing task to a distributed system on which the distributed cache is based, so that the distributed system determines whether a preset task queue stores a clearing task corresponding to the target data, if yes, when a monitor monitors that the target data in the database is changed, the task queue is cleared according to the clearing task corresponding to the target data stored in the task queue or the cache clearing task, otherwise, the cache clearing task is added to the task queue, and when the monitor monitors that the target data in the database is changed, the task included in the task queue is executed, so as to clear the target data cached in the distributed cache.
The present specification also provides a computer readable storage medium storing a computer program operable to perform a method of flushing a cache as provided in fig. 1 above.
The present specification also provides a schematic structural diagram of an electronic device corresponding to fig. 1 shown in fig. 5. At the hardware level, as shown in fig. 5, the electronic device includes a processor, an internal bus, a network interface, a memory, and a nonvolatile storage, and may of course include hardware required by other services. The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the same to implement the method for clearing the cache as described in fig. 1.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (e.g., field programmable gate array (Field Programmable Gate Array, FPGA)) is an integrated circuit whose logic function is determined by the programming of the device by a user. A designer programs to "integrate" a digital system onto a PLD without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented by using "logic compiler" software, which is similar to the software compiler used in program development and writing, and the original code before the compiling is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but not just one of the hdds, but a plurality of kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), lava, lola, myHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present specification.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present description is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that 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.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present disclosure and is not intended to limit the disclosure. Various modifications and alterations to this specification will become apparent to those skilled in the art. Any modifications, equivalent substitutions, improvements, or the like, which are within the spirit and principles of the present description, are intended to be included within the scope of the claims of the present description.

Claims (10)

1. A method for flushing a cache, comprising:
receiving a data processing request;
determining target data which needs to be called from a database according to the data processing request;
creating annotation information for the target data, wherein the annotation information at least comprises table information of a table storing the target data in a database, and key information of the target data in a distributed cache;
according to the target data, carrying out data processing, and caching the target data in the distributed cache;
and when the change of the target data in the database is monitored by a deployed monitor, clearing the target data cached in the distributed cache based on the annotation information.
2. The method of claim 1, wherein the data types of the data cached in the distributed cache comprise a first type and a second type, wherein the first type of data has a higher traffic priority than the second type of data;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises a synchronous clearing mode;
creating annotation information for the target data, specifically including:
Determining a data type of the target data;
if the data type of the target data is determined to be the first type, annotation information containing mode information of the synchronous clearing mode is created for the target data.
3. The method of claim 1, wherein the data types of the data cached in the distributed cache comprise a first type and a second type, wherein the first type of data has a higher traffic priority than the second type of data;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises an asynchronous clearing mode;
creating annotation information for the target data, specifically including:
determining a data type of the target data;
if the data type of the target data is determined to be the second type, annotation information containing mode information of the asynchronous clear mode is created for the target data.
4. The method of claim 2, wherein when the target data in the database is monitored to be changed by a deployed monitor, the target data cached in the distributed cache is purged based on the annotation information, specifically comprising:
When the target data in the database is monitored to be changed through a locally deployed monitor, a first clearing instruction is generated according to the annotation information, so that the target data in the distributed cache is cleared according to the first clearing instruction.
5. The method of claim 3, wherein when the target data in the database is monitored to be changed by a deployed monitor, the target data cached in the distributed cache is purged based on the annotation information, specifically comprising:
creating a cache clearing task for the target data according to the annotation information;
and sending the cache clearing task to a distributed system based on distributed caches, so that the distributed system generates a second clearing instruction when a monitor deployed in the distributed system monitors that the target data in the database is changed, and the cache clearing task is executed through the second clearing instruction so as to clear the target data cached in the distributed caches.
6. The method as claimed in claim 5, wherein sending the cache flush task to a distributed system on which a distributed cache is based, so that the distributed system generates a second flush instruction when a listener deployed in the distributed system listens to changes to the target data in the database, so as to execute the cache flush task through the second flush instruction, so as to flush the target data cached in the distributed cache, specifically including:
And sending the cache clearing task to a distributed system on which the distributed cache is based, so that the distributed system judges whether a preset task queue stores a clearing task corresponding to the target data, if so, when responding to the monitor to monitor the change of the target data in the database, clearing the target data cached in the distributed cache according to the clearing task corresponding to the target data stored in the task queue or the cache clearing task, otherwise, adding the cache clearing task into the task queue, and executing the task contained in the task queue when responding to the monitor to monitor the change of the target data in the database, so as to clear the target data cached in the distributed cache.
7. An apparatus for flushing a cache, comprising:
the receiving module is used for receiving the data processing request;
the determining module is used for determining target data which needs to be called from a database according to the data processing request;
the creating module is used for creating annotation information aiming at the target data, wherein the annotation information at least comprises table information of a table for storing the target data in a database, and key information of the target data in a distributed cache;
The caching module is used for carrying out data processing according to the target data and caching the target data in the distributed cache;
and the clearing module is used for clearing the target data cached in the distributed cache based on the annotation information when the deployed monitor monitors that the target data in the database is changed.
8. The apparatus of claim 7, wherein the data types of the data cached in the distributed cache comprise a first type and a second type, wherein the first type of data has a higher traffic priority than the second type of data;
the annotation information also comprises mode information of a clearing mode of the target data, wherein the clearing mode comprises a synchronous clearing mode;
the creation module is specifically configured to determine a data type of the target data; if the data type of the target data is determined to be the first type, annotation information containing mode information of the synchronous clearing mode is created for the target data.
9. A computer readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1-6.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of the preceding claims 1-6 when executing the program.
CN202311464151.8A 2023-11-06 2023-11-06 Method and device for clearing cache, storage medium and electronic equipment Active CN117193670B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311464151.8A CN117193670B (en) 2023-11-06 2023-11-06 Method and device for clearing cache, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311464151.8A CN117193670B (en) 2023-11-06 2023-11-06 Method and device for clearing cache, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN117193670A true CN117193670A (en) 2023-12-08
CN117193670B CN117193670B (en) 2024-01-30

Family

ID=88983589

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311464151.8A Active CN117193670B (en) 2023-11-06 2023-11-06 Method and device for clearing cache, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN117193670B (en)

Citations (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003034179A2 (en) * 2001-10-16 2003-04-24 Outtask, Inc. System and method for managing booking and expensing of travel products and services
US20100180208A1 (en) * 2009-01-15 2010-07-15 Kasten Christopher J Server side data cache system
CN107908777A (en) * 2017-12-01 2018-04-13 云南民族大学 A kind of built-in browser removes data cached method
CN108052280A (en) * 2017-11-29 2018-05-18 努比亚技术有限公司 A kind of data cached delet method, terminal and computer readable storage medium
CN110008224A (en) * 2019-03-08 2019-07-12 阿里巴巴集团控股有限公司 A kind of db transaction processing method and processing device
CN110019340A (en) * 2017-12-08 2019-07-16 北京新媒传信科技有限公司 Data storage/read method, apparatus and system
WO2019179235A1 (en) * 2018-03-23 2019-09-26 阿里巴巴集团控股有限公司 Data caching method, device and system
CN111984191A (en) * 2020-08-05 2020-11-24 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Multi-client caching method and system supporting distributed storage
CN112487037A (en) * 2020-12-08 2021-03-12 平安国际智慧城市科技股份有限公司 Cache data processing method and device, computer equipment and storage medium
CN112506961A (en) * 2020-12-28 2021-03-16 浪潮云信息技术股份公司 Method for improving data query efficiency
CN113760991A (en) * 2021-03-25 2021-12-07 北京京东拓先科技有限公司 Data operation method and device, electronic equipment and computer readable medium
CN114925078A (en) * 2022-05-26 2022-08-19 中国平安人寿保险股份有限公司 Data updating method, system, electronic device and storage medium
CN115048392A (en) * 2022-05-24 2022-09-13 青岛海尔科技有限公司 Data deletion method and device, storage medium and electronic device
CN115328406A (en) * 2022-08-29 2022-11-11 北京达佳互联信息技术有限公司 Data writing and acquiring method and device, electronic equipment and computer medium
CN115687402A (en) * 2022-06-10 2023-02-03 四川虹美智能科技有限公司 Method for realizing consistency of cache data and database data
CN115757495A (en) * 2022-11-21 2023-03-07 中国平安财产保险股份有限公司 Cache data processing method and device, computer equipment and storage medium
CN115964395A (en) * 2022-12-30 2023-04-14 深圳云天励飞技术股份有限公司 Data reading method and device and electronic equipment
CN116088892A (en) * 2022-12-07 2023-05-09 上海品顺信息科技有限公司 Distributed service system configuration changing method, device, computer equipment and medium
WO2023116109A1 (en) * 2021-12-23 2023-06-29 郑州云海信息技术有限公司 Request processing method and apparatus, and device and non-volatile readable storage medium

Patent Citations (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003034179A2 (en) * 2001-10-16 2003-04-24 Outtask, Inc. System and method for managing booking and expensing of travel products and services
US20100180208A1 (en) * 2009-01-15 2010-07-15 Kasten Christopher J Server side data cache system
CN108052280A (en) * 2017-11-29 2018-05-18 努比亚技术有限公司 A kind of data cached delet method, terminal and computer readable storage medium
CN107908777A (en) * 2017-12-01 2018-04-13 云南民族大学 A kind of built-in browser removes data cached method
CN110019340A (en) * 2017-12-08 2019-07-16 北京新媒传信科技有限公司 Data storage/read method, apparatus and system
WO2019179235A1 (en) * 2018-03-23 2019-09-26 阿里巴巴集团控股有限公司 Data caching method, device and system
CN110008224A (en) * 2019-03-08 2019-07-12 阿里巴巴集团控股有限公司 A kind of db transaction processing method and processing device
CN111984191A (en) * 2020-08-05 2020-11-24 华东计算技术研究所(中国电子科技集团公司第三十二研究所) Multi-client caching method and system supporting distributed storage
CN112487037A (en) * 2020-12-08 2021-03-12 平安国际智慧城市科技股份有限公司 Cache data processing method and device, computer equipment and storage medium
CN112506961A (en) * 2020-12-28 2021-03-16 浪潮云信息技术股份公司 Method for improving data query efficiency
CN113760991A (en) * 2021-03-25 2021-12-07 北京京东拓先科技有限公司 Data operation method and device, electronic equipment and computer readable medium
WO2023116109A1 (en) * 2021-12-23 2023-06-29 郑州云海信息技术有限公司 Request processing method and apparatus, and device and non-volatile readable storage medium
CN115048392A (en) * 2022-05-24 2022-09-13 青岛海尔科技有限公司 Data deletion method and device, storage medium and electronic device
CN114925078A (en) * 2022-05-26 2022-08-19 中国平安人寿保险股份有限公司 Data updating method, system, electronic device and storage medium
CN115687402A (en) * 2022-06-10 2023-02-03 四川虹美智能科技有限公司 Method for realizing consistency of cache data and database data
CN115328406A (en) * 2022-08-29 2022-11-11 北京达佳互联信息技术有限公司 Data writing and acquiring method and device, electronic equipment and computer medium
CN115757495A (en) * 2022-11-21 2023-03-07 中国平安财产保险股份有限公司 Cache data processing method and device, computer equipment and storage medium
CN116088892A (en) * 2022-12-07 2023-05-09 上海品顺信息科技有限公司 Distributed service system configuration changing method, device, computer equipment and medium
CN115964395A (en) * 2022-12-30 2023-04-14 深圳云天励飞技术股份有限公司 Data reading method and device and electronic equipment

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
KAIYANG LIU 等: ""Adaptive and Scalable Caching With Erasure Codes in Distributed Cloud-Edge Storage Systems"", 《IEEE TRANSACTIONS ON CLOUD COMPUTING》, vol. 11, no. 2, pages 1840 - 1853 *
杨谦 等: ""面向分布式系统的高性能缓存管理软件设计及应用"", 《信息技术与信息化》, no. 05, pages 71 - 73 *
江勇 等: ""基于变化数据捕获机制的分布式缓存一致性策略"", 《计算机系统应用》, vol. 25, no. 12, pages 149 - 154 *

Also Published As

Publication number Publication date
CN117193670B (en) 2024-01-30

Similar Documents

Publication Publication Date Title
KR20190091484A (en) Blockchain consensus method and device
CN108628688B (en) Message processing method, device and equipment
CN106775498B (en) Cache data synchronization method and system
CN110162512B (en) Log retrieval method, device and storage medium
KR20210121315A (en) Database syncing
CN110765165B (en) Method, device and system for synchronously processing cross-system data
CN110389989B (en) Data processing method, device and equipment
US9893972B1 (en) Managing I/O requests
CN117193670B (en) Method and device for clearing cache, storage medium and electronic equipment
US10565202B2 (en) Data write/import performance in a database through distributed memory
WO2024001025A1 (en) Pre-execution cache data cleaning method and blockchain node
CN116048977B (en) Test method and device based on data reduction
CN111913807A (en) Event processing method, system and device based on multiple storage areas
WO2024066005A1 (en) Method and apparatus for replaying blockchain transaction
CN110704401A (en) Data processing method and device, electronic equipment and storage medium
US11494099B2 (en) Method, device, and computer program product for managing storage system
CN116166673A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN115033350A (en) Execution method and device of distributed transaction
CN109408496A (en) A kind of method and device reducing data redundancy
CN114785662A (en) Storage management method, device, equipment and machine readable storage medium
CN110019023B (en) Method, device and equipment for pushing mechanism information message
CN110502551A (en) Data read-write method, system and infrastructure component
CN107645541B (en) Data storage method and device and server
CN107025266B (en) Service data processing method and device
CN112799863A (en) Method and apparatus for outputting information

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