Data cache refreshing method and device, storage medium and electronic device
By setting up a listener program and built-in trigger in the database, detecting user information changes and refreshing data cache, the problem of single and slow functions of data cache refresh scheme in the existing technology is solved, and real-time data cache under low budgets is realized Refresh improves the flexibility and accuracy of data transmission.
Patent Information
- Application Number
- CN202411287432.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2024-12-31
AI Technical Summary
In the prior art, the refresh solution of data cache has the problems of single functions, slow speed and high budget, and it is difficult to realize real-time refresh of database data cache under low budget conditions.
By setting up a monitor program in the database to monitor the table, detect changes in user information and write preset identifiers, and then refresh the data cache in real time, using the combination of built-in triggers and listeners to achieve rapid refresh of the data cache.
Real-time refresh of database data cache is realized under low budget, improving the flexibility of video data transmission and the accuracy of user interaction, and is suitable for small and medium-sized systems.
Smart Images

Figure CN119226343A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a data cache refresh method and device, a storage medium, and an electronic device. Background Art
[0002] As the number of users increases, the amount of data stored in the database is increasing. Directly querying the database can no longer meet the needs of fast interaction with users, so a data cache mechanism has emerged. However, how to refresh the data cache and ensure the accuracy of the interactive data has become a problem that needs to be solved urgently.
[0003] In the related art, the solutions for solving the problem of refreshing data cache have the following problems: 1) the application scenario function is single and cannot guarantee the real-time refresh of data; 2) the refresh speed is slow and cannot meet the requirements of fast interaction; 3) the budget is high and it is not suitable for small and medium-sized systems. Therefore, in the related art, there is a lack of solutions for real-time refresh of the data cache corresponding to the database under low budget conditions.
[0004] In the related technologies, there is no effective solution for the problem of how to refresh the data cache corresponding to the database in real time under low budget.
[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention
[0006] The embodiments of the present application provide a data cache refresh method and device, a storage medium and an electronic device to at least solve the problem in the related art of how to refresh the data cache corresponding to the database in real time under a low budget.
[0007] According to one aspect of an embodiment of the present application, a method for refreshing a data cache is provided, comprising: monitoring a first table through a monitoring program set in a database to obtain a first monitoring result, wherein the first table is used to be written with a preset identifier when user information in the database changes, wherein the preset identifier is used to indicate that the user information has changed; when the first monitoring result indicates that the preset identifier is written into the first table, refreshing the data cache corresponding to the database.
[0008] In an exemplary embodiment, a first table is monitored by a monitoring program set in a database to obtain a first monitoring result, including: obtaining a second table corresponding to the first table at the current moment through the monitoring program; comparing the second table with a third table to obtain a comparison result, wherein the third table is a table corresponding to the first table obtained by the monitoring program at a moment before the current moment; when the comparison result indicates that the second table is consistent with the third table, determining that the preset identifier is not written into the first table.
[0009] In an exemplary embodiment, after comparing the second table with the third table to obtain a comparison result, the method further includes: if the comparison result indicates that the second table is inconsistent with the third table, determining that the preset identifier is written into the first table.
[0010] In an exemplary embodiment, the first table is monitored by a monitoring program set in the database, and before obtaining a first monitoring result, the method also includes: detecting a fourth table through a trigger built into the database to obtain a detection result, wherein the fourth table is a table in the database for recording target user information, wherein the target user information is user information that has changed in the database; when the detection result indicates that the target user information is newly added to the fourth table, the preset identifier is written into the first table through the trigger.
[0011] In an exemplary embodiment, refreshing the data cache corresponding to the database includes: acquiring the target user information in the fourth table through the listening program; and refreshing the data cache through the target user information.
[0012] In an exemplary embodiment, the fourth table is detected by a trigger built into the database, and before the detection result is obtained, the method also includes: receiving a data modification instruction initiated by a user; performing a preset modification operation on the user information in the database according to the data modification instruction, wherein the preset modification operation includes at least one of the following: a new addition operation, a deletion operation, and a modification operation; determining the user information on which the preset modification operation has been performed as the target user information; and writing the target user information into the fourth table.
[0013] In an exemplary embodiment, refreshing the data cache corresponding to the database includes: determining the identification type of the preset identification, wherein the identification type includes: a specific identification, a changed user information; when the identification type indicates that the preset identification is the changed user information, refreshing the data cache through the preset identification.
[0014] According to another aspect of an embodiment of the present application, a data cache refresh device is also provided, including: a monitoring module, used to monitor a first table through a monitoring program set in a database to obtain a first monitoring result, wherein the first table is used to be written with a preset identifier when user information in the database changes, wherein the preset identifier is used to indicate that the user information has changed; a refresh module, used to refresh the data cache corresponding to the database when the first monitoring result indicates that the preset identifier is written into the first table.
[0015] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned data cache refresh method when running.
[0016] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the data cache refresh method through the computer program.
[0017] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method for refreshing the data cache is implemented.
[0018] Through the present application, the first table is monitored through a monitoring program set in the database to obtain a first monitoring result, wherein the first table is used to be written with a preset identifier when the user information in the database changes, wherein the preset identifier is used to indicate that the user information has changed; when the first monitoring result indicates that the preset identifier is written into the first table, the data cache corresponding to the database is refreshed. In other words, by monitoring whether the preset identifier is written into the first table through the monitoring program, fewer resources are consumed, which is suitable for refreshing scenarios of low-budget data caches; and, once it is determined through the monitoring program that the preset identifier is written into the first table, the data cache can be refreshed in real time and quickly. Therefore, the above technical solution is adopted to solve the problem of how to refresh the data cache corresponding to the database in real time under low budget conditions in the related technology; and improve the flexibility of video data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] Figure 1 It is a hardware environment diagram of an optional data cache refresh method according to an embodiment of the present application;
[0022] Figure 2 is a flowchart (I) of an optional data cache refresh method according to an embodiment of the present application;
[0023] Figure 3 is a flow chart (II) of an optional data cache refresh method according to an embodiment of the present application;
[0024] Figure 4 is a flowchart (III) of an optional data cache refresh method according to an embodiment of the present application;
[0025] Figure 5 It is a structural block diagram of an optional data cache refresh device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] According to one aspect of an embodiment of the present application, a method for refreshing a data cache is provided. The method for refreshing a data cache is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the method for refreshing a data cache can be applied to Figure 1 In the hardware environment shown in FIG. 1 , a plurality of terminal devices 102 and a server 104 are formed. Figure 1 As shown, the server 104 is connected to multiple terminal devices 102 via a network, and can be used to provide services (such as application services, etc.) for the terminals or clients installed on the terminals. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0029] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0030] In this embodiment, a data cache refresh method is provided, including but not limited to being applied in the above hardware environment, or running in a database.
[0031] Figure 2 1 is a flow chart of a method for refreshing a data cache according to an embodiment of the present application (I), the flow comprising the following steps:
[0032] Step S202: monitoring the first table through a monitoring program set in the database to obtain a first monitoring result, wherein the first table is used to be written with a preset mark when the user information in the database changes, wherein the preset mark is used to indicate that the user information has changed;
[0033] Step S204: when the first monitoring result indicates that the preset identifier is written into the first table, refreshing the data cache corresponding to the database.
[0034] Through the above steps, the first table is monitored through the monitoring program set in the database to obtain the first monitoring result, wherein the first table is used to be written with a preset mark when the user information in the database changes, wherein the preset mark is used to indicate that the user information has changed; when the first monitoring result indicates that the preset mark is written into the first table, the data cache corresponding to the database is refreshed. In other words, by monitoring whether the preset mark is written into the first table through the monitoring program, less resources are consumed, which is suitable for low-budget data cache refresh scenarios; and once it is determined through the monitoring program that the preset mark is written into the first table, the data cache can be refreshed in real time and quickly. Therefore, the above technical solution solves the problem of how to refresh the data cache corresponding to the database in real time under low budget conditions in the related technology; and improves the flexibility of video data transmission.
[0035] It should be noted that the database and data cache are two different storage systems, and the relationship between them is complementary. The database stores persistent data, while the data cache stores copies of frequently accessed data in the database. The introduction of data cache can improve the performance and response speed of the system, reduce frequent access to the database, and thus improve the throughput and concurrent processing capabilities of the system. The consistency of data between the database and the data cache is guaranteed through the data synchronization mechanism to ensure the accuracy and integrity of the data. Through reasonable design and configuration, the database and data cache can work together to improve the overall performance of the system and user experience.
[0036] In an exemplary embodiment, the first table is monitored by a monitoring program set in the database, and before obtaining a first monitoring result, the method also includes: detecting a fourth table through a trigger built into the database to obtain a detection result, wherein the fourth table is a table in the database for recording target user information, wherein the target user information is user information that has changed in the database; when the detection result indicates that the target user information is newly added to the fourth table, the preset identifier is written into the first table through the trigger.
[0037] Optionally, before the fourth table is detected by the built-in trigger of the database and the detection result is obtained, the method also includes: receiving a data modification instruction initiated by a user; performing a preset modification operation on the user information in the database according to the data modification instruction, wherein the preset modification operation includes at least one of the following: a new operation, a deletion operation, and a modification operation; determining the user information on which the preset modification operation has been performed as the target user information; and writing the target user information into the fourth table.
[0038] It should be noted that in the embodiment of the present application, the database may be a MYSQL database. A user information table (equivalent to the fourth table) is provided in the database. When the user information in the database is modified, the modified user information (equivalent to the target user information) will be written into the user information table. A trigger is provided in the database for monitoring the user information table. When the user information table records the target user information, a preset identifier will be written into the first table provided in the database. More specifically, the modified user information includes: the newly added user information corresponding to the add operation, the deleted user information corresponding to the delete operation, and the modified user information corresponding to the modify operation.
[0039] It should also be noted that the preset identifier written into the first table includes one of the following: a specific identifier, target user information; wherein the specific identifier is used to indicate that the database has received a data modification instruction initiated by a user, and there is user information on which a modification operation has been performed. The preset identifier can be a fixed identifier or an identifier associated with the timing of the data modification instruction. The preset identifier includes the target user information, that is, the target user information can be directly written into the first table.
[0040] In an exemplary embodiment, the first table is monitored by a monitoring program set in the database to obtain a first monitoring result. Figure 3 As shown, it includes steps S302 to S306:
[0041] Step S302: obtaining, through the monitoring program, a second table corresponding to the first table at the current moment;
[0042] Step S304: Compare the second table with the third table to obtain a comparison result, wherein the third table is a table corresponding to the first table at a time point before the current time point obtained by the monitoring program;
[0043] Step S306: when the comparison result indicates that the second table is consistent with the third table, determining that the preset identifier is not written into the first table.
[0044] Furthermore, after comparing the second table with the third table to obtain a comparison result, the method further includes: if the comparison result indicates that the second table is inconsistent with the third table, determining that the preset identifier is written into the first table.
[0045] It is understandable that in the embodiment of the present application, the monitoring program polls and monitors the first table at a preset time interval, and the preset time interval is the time interval between the current moment and the previous moment. By comparing the two tables monitored at the current moment and the previous moment, if the two tables are consistent, the preset mark is not written in the first table, and if the two tables are consistent, the preset mark is written in the first table.
[0046] Optionally, refreshing the data cache corresponding to the database according to different types of preset identifiers includes the following two solutions:
[0047] Solution 1, when the preset identifier is a specific identifier, refreshing the data cache corresponding to the database includes: acquiring the target user information in the fourth table through the monitoring program; and refreshing the data cache through the target user information.
[0048] The cache update program is called through the listening program; the target user information in the fourth table is read through the cache update program to update the data cache. The target user information in the fourth table is obtained, including querying the time sequence information of all target user information in the fourth table, and taking the user information with the latest time sequence information among all target user information as the target user information.
[0049] Solution 2, when the preset identifier is the target user information, refreshing the data cache corresponding to the database, including: determining the identifier type of the preset identifier, wherein the identifier type includes: a specific identifier, a changed user information (i.e., the target user information); when the identifier type indicates that the preset identifier is the changed user information, refreshing the data cache through the preset identifier.
[0050] Therefore, the data cache is refreshed to ensure the accuracy of the interaction data obtained by the user through the data cache.
[0051] Obviously, the embodiments described above are only some embodiments of the present application, not all embodiments. In order to better understand the above data cache refresh method, the above process is described below in conjunction with the embodiments, but it is not intended to limit the technical solutions of the embodiments of the present application, specifically:
[0052] In the related art, in order to solve the problem of refreshing the data cache, there are three data refresh schemes, including: 1. The expiration automatic deletion scheme, which means setting an expiration date for the cached data, automatically deleting it when it expires, and passively waiting for the program to trigger and then cache the latest data. This scheme cannot meet the real-time refresh of the cached data and may show inaccurate data to the user. 2. The program active refresh scheme, which means refreshing the cached data at the same time after the program updates the data in the database. This scheme may take a long time and cannot meet the fast interaction with the user. 3. Monitor the database binlog log and refresh the cached data in real time. This scheme has a high budget cost and high maintenance cost, and is not suitable for the refresh strategy of small and medium-sized systems. Therefore, the optional embodiment of the present application provides a solution for completing the refresh of cached data in real time under the premise of a low budget.
[0053] The data cache refresh solution provided by the optional embodiment of the present application is as follows: Figure 4 As shown, including:
[0054] Step S401: The user initiates a data query.
[0055] Step S402: The cached data in the user information cache (equivalent to the data cache) quickly responds to the user's query.
[0056] Step S403: The user initiates data modification, and the modified user information is saved to the user information table (equivalent to the fourth table) in the database.
[0057] Step S404: The database responds to the user in real time, and the data modification is completed.
[0058] Step S405: The trigger monitors the user information table;
[0059] Step S406: If it is monitored that the modified user information (equivalent to the target user information) is written into the user information table, the trigger automatically stores an identification data (equivalent to the preset identification) into the monitoring table (equivalent to the first table).
[0060] Step S407: the monitoring program monitors the monitoring table;
[0061] Step S408: monitoring that data (equivalent to a preset identifier) is stored in the monitoring table;
[0062] Step S409: triggering data cache update.
[0063] Step S410: The user queries data from the user information cache.
[0064] Step S411: The user information cache responds with the latest cache data.
[0065] It should be noted that the user is the user of the system where the database is located. The user information cache is a cache that stores user information, which is consistent with the MYSQL user information table data in principle. The MYSQL user information table is a database table that stores user-related information. The MYSQL trigger is a trigger that comes with the MYSQL database. It can automatically store a piece of data in another table when the MYSQL data table changes. MYSQL monitoring table: When the data in the user information table changes, the MYSQL trigger will automatically store a piece of data in the monitoring table to indicate that the user information has changed. Microservice monitoring program: A program application used to connect the database monitoring table and the user information cache in series. When the monitoring table changes, the user information cache can be updated in real time.
[0066] In summary, the optional embodiment of the present application uses a combination of MYSQL's own triggers and program listeners to refresh the data cache layer. Compared with the three cache refresh solutions in the related art, it has the advantages of low learning cost, simple operation and maintenance, and high real-time performance.
[0067] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0068] In this embodiment, a data cache refresh device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0069] Figure 5 : is a structural block diagram of an optional data cache refresh device according to an embodiment of the present application, the device comprising:
[0070] A monitoring module 52, configured to monitor the first table through a monitoring program set in the database to obtain a first monitoring result, wherein the first table is used to be written with a preset mark when the user information in the database changes, wherein the preset mark is used to indicate that the user information has changed;
[0071] The refresh module 54 is configured to refresh the data cache corresponding to the database when the first monitoring result indicates that the preset identifier is written into the first table.
[0072] Through the above-mentioned device, the first table is monitored through the monitoring program set in the database to obtain the first monitoring result, wherein the first table is used to be written with a preset mark when the user information in the database changes, wherein the preset mark is used to indicate that the user information has changed; when the first monitoring result indicates that the preset mark is written into the first table, the data cache corresponding to the database is refreshed. In other words, by monitoring whether the preset mark is written into the first table through the monitoring program, less resources are consumed, which is suitable for low-budget data cache refresh scenarios; and once it is determined through the monitoring program that the preset mark is written into the first table, the data cache can be refreshed in real time and quickly. Therefore, the above-mentioned technical solution solves the problem of how to refresh the data cache corresponding to the database in real time under low budget conditions in the related technology; and improves the flexibility of video data transmission.
[0073] In an exemplary embodiment, the monitoring module 52 is used to: obtain a second table corresponding to the first table at the current moment through the monitoring program; compare the second table with a third table to obtain a comparison result, wherein the third table is a table corresponding to the first table obtained by the monitoring program at a moment before the current moment; when the comparison result indicates that the second table is consistent with the third table, determine that the preset identifier is not written into the first table.
[0074] In an exemplary embodiment, the monitoring module 52 is configured to: determine that the preset identifier is written into the first table when the comparison result indicates that the second table is inconsistent with the third table.
[0075] After comparing the second table with the third table to obtain a comparison result, the method further includes: if the comparison result indicates that the second table is inconsistent with the third table, determining that the preset identifier is written into the first table.
[0076] In an exemplary embodiment, the device also includes a first writing module, which is used to: detect a fourth table through a trigger built into the database to obtain a detection result, wherein the fourth table is a table in the database for recording target user information, wherein the target user information is user information that has changed in the database; when the detection result indicates that the target user information has been added to the fourth table, the preset identifier is written into the first table through the trigger.
[0077] In an exemplary embodiment, the refresh module 54 is used to: obtain the target user information in the fourth table through the listening program; and refresh the data cache through the target user information.
[0078] The cache update program is called through the listening program; the target user information in the fourth table is read through the cache update program to update the data cache. The target user information in the fourth table is obtained, including querying the time sequence information of all target user information in the fourth table, and taking the user information with the latest time sequence information among all target user information as the target user information.
[0079] In an exemplary embodiment, the device also includes a second writing module, which is used to: receive a data modification instruction initiated by a user; perform a preset modification operation on the user information in the database according to the data modification instruction, wherein the preset modification operation includes at least one of the following: a new operation, a deletion operation, and a modification operation; determine the user information on which the preset modification operation has been performed as the target user information; and write the target user information into the fourth table.
[0080] It should be noted that in the embodiment of the present application, the database may be a MYSQL database. A user information table (equivalent to the fourth table) is set in the database. When the user information in the database is modified, the modified user information (equivalent to the target user information) will be written into the user information table. A trigger is set in the database. The user monitors the user information table. When the user information table records the target user information, the preset identifier will be written into the first table set in the database.
[0081] It should also be noted that the preset identifier written into the first table includes one of the following: a specific identifier, target user information; wherein the specific identifier is used to indicate that the database has received a data modification instruction initiated by a user, and there is user information on which a modification operation has been performed. The preset identifier can be a fixed identifier or an identifier associated with the timing of the data modification instruction. The preset identifier includes the target user information, that is, the target user information can be directly written into the first table.
[0082] In an exemplary embodiment, the refresh module 54 is used to: determine the identification type of the preset identification, wherein the identification type includes: a specific identification, and changed user information; and when the identification type indicates that the preset identification is changed user information, refresh the data cache by the preset identification. Thus, the data cache is refreshed to ensure the accuracy of the interaction data obtained by the user through the data cache.
[0083] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0084] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0085] S1, monitoring a first table through a monitoring program set in a database to obtain a first monitoring result, wherein the first table is used to be written with a preset identifier when user information in the database changes, wherein the preset identifier is used to indicate that the user information has changed;
[0086] S2: When the first monitoring result indicates that the preset identifier is written into the first table, refresh the data cache corresponding to the database.
[0087] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0088] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0089] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0090] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0091] S1, monitoring a first table through a monitoring program set in a database to obtain a first monitoring result, wherein the first table is used to be written with a preset identifier when user information in the database changes, wherein the preset identifier is used to indicate that the user information has changed;
[0092] S2: When the first monitoring result indicates that the preset identifier is written into the first table, refresh the data cache corresponding to the database.
[0093] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0094] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0095] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0096] S1, monitoring a first table through a monitoring program set in a database to obtain a first monitoring result, wherein the first table is used to be written with a preset identifier when user information in the database changes, wherein the preset identifier is used to indicate that the user information has changed;
[0097] S2: When the first monitoring result indicates that the preset identifier is written into the first table, refresh the data cache corresponding to the database.
[0098] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0099] An embodiment of the present application also provides a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0100] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0101] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0102] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for refreshing a data cache, characterized in that: include: The first table is monitored by a monitoring program set in the database to obtain a first monitoring result, wherein the first table is used to be written with a preset mark when the user information in the database changes, wherein the preset mark is used to indicate that the user information has changed; When the first monitoring result indicates that the preset identifier is written into the first table, the data cache corresponding to the database is refreshed.
2. The data cache refresh method according to claim 1, characterized in that: The first table is monitored by a monitoring program set in the database to obtain a first monitoring result, including: Acquire, through the monitoring program, a second table corresponding to the first table at the current moment; Compare the second table with a third table to obtain a comparison result, wherein the third table is a table corresponding to the first table at a time before the current time obtained by the monitoring program; When the comparison result indicates that the second table is consistent with the third table, it is determined that the preset identifier is not written into the first table.
3. The data cache refresh method according to claim 2, characterized in that: After comparing the second table with the third table to obtain a comparison result, the method further includes: When the comparison result indicates that the second table is inconsistent with the third table, it is determined that the preset identifier is written into the first table.
4. The data cache refresh method according to claim 1, characterized in that: Before obtaining the first monitoring result by monitoring the first table through the monitoring program set in the database, the method further includes: A fourth table is detected by a trigger built into the database to obtain a detection result, wherein the fourth table is a table in the database for recording target user information, wherein the target user information is user information that has changed in the database; When the detection result indicates that the target user information is newly added to the fourth table, the preset identifier is written into the first table through the trigger.
5. The data cache refresh method according to claim 4, characterized in that: Refreshing the data cache corresponding to the database includes: Acquire the target user information in the fourth table through the monitoring program; The data cache is refreshed using the target user information.
6. The data cache refresh method according to claim 4, characterized in that: Before detecting the fourth table by using the built-in trigger of the database to obtain the detection result, the method further includes: Receive data modification instructions initiated by users; Performing a preset modification operation on the user information in the database according to the data modification instruction, wherein the preset modification operation includes at least one of the following: a adding operation, a deleting operation, and a modifying operation; determining the user information on which the preset modification operation is performed as the target user information; The target user information is written into the fourth table.
7. The data cache refresh method according to claim 1, characterized in that: Refreshing the data cache corresponding to the database includes: Determine the identification type of the preset identification, wherein the identification type includes: a specific identification and changed user information; When the identifier type indicates that the preset identifier is changed user information, the data cache is refreshed using the preset identifier.
8. A data cache refresh device, characterized in that: include: A monitoring module, used for monitoring the first table through a monitoring program set in the database to obtain a first monitoring result, wherein the first table is used to be written with a preset mark when the user information in the database changes, wherein the preset mark is used to indicate that the user information has changed; A refresh module is used to refresh the data cache corresponding to the database when the first monitoring result indicates that the preset identifier is written into the first table.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
