Method, system and device for synchronizing MySQL data to Redis cache in real time and medium
Through Canal, Kafka and Flink technologies, real-time synchronization of MySQL data and Redis cache is achieved, solving the problems of low efficiency and untimely updates in the existing technology, and achieving efficient, stable and flexible data synchronization.
Patent Information
- Application Number
- CN202411928851.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-22
Smart Images

Figure CN119862190A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of cache update, and relates to a method, system, device and medium for synchronizing MySQL data to Redis cache in real time. Background Art
[0002] MySQL is the most commonly used relational database in enterprise systems, but MySQL databases often cannot meet the query requirements of high concurrency and low latency. Therefore, cache technology is widely used. Redis, as a high-performance in-memory database, is the first choice for cache technology. However, synchronizing MySQL data with Redis cache is a key issue.
[0003] In the prior art, cache is usually updated manually or by developing a program. However, this method cannot adapt to changing needs and has the problems of low efficiency and untimely cache update. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a method, system, device and medium for real-time synchronization of MySQL data to Redis cache. The method, system, device and medium can adapt to changing needs and have the characteristics of high efficiency and timely cache update.
[0005] To achieve the above object, the present invention discloses a method for real-time synchronization of MySQL data to Redis cache, comprising:
[0006] Canal captures MySQL data changes, obtains MySQL change data, and sends the MySQL change data to the Kafka topic;
[0007] Configure synchronization rules;
[0008] Through the Flink job, the MySQL change data in the Kafka topic is synchronized to the Redis cache according to the synchronization rules.
[0009] The method for real-time synchronization of MySQL data to Redis cache of the present invention is further improved in that:
[0010] Furthermore, the process of the Canal capturing MySQL data changes, obtaining MySQL change data, and sending the MySQL change data to the Kafka topic is as follows:
[0011] Install the Canal service on the server and configure Canal to connect to the MySQL database and read the MySQL binlog log;
[0012] Canal parses MySQL binlog logs, captures MySQL change data, and generates JSON format messages;
[0013] Canal sends MySQL change data to Kafka topics in JSON format.
[0014] Furthermore, the process of configuring synchronization rules is as follows:
[0015] Read the table and table field information of the MySQL data source, select the table to be synchronized, the field to be synchronized in the table, and set the data filtering conditions;
[0016] Define the data format of Key and Value in Redis cache;
[0017] Store synchronization rules in a relational database for use by Flink jobs.
[0018] Furthermore, the process of synchronizing the MySQL change data in the Kafka topic to the Redis cache through the Flink job according to the synchronization rules is as follows:
[0019] Create a Flink job, subscribe to the Kafka topic, and read MySQL change data in real time;
[0020] After the Flink job is started, it reads the synchronization rules saved in the relational database, obtains the tables, fields, data filtering conditions, and Redis data formats to be synchronized to the Redis cache, and sets the Flink job to read the saved synchronization rules every hour.
[0021] Match the MySQL binlog data that needs to be synchronized according to the filtering conditions set in the synchronization rules;
[0022] When the operation type in the binlog data is DELETE, the Redis deletion interface is called to delete the cache; when the operation type in the binlog data is INSERT or UPDATE, the Key and Value of the Redis data are assembled according to the Redis data format configured by the rule;
[0023] Call the Redis add data interface to send the assembled Redis data to the Redis service.
[0024] The present invention discloses a system for real-time synchronization of MySQL data to Redis cache, comprising:
[0025] The acquisition module is used for Canal to capture MySQL data changes, obtain MySQL change data, and send the MySQL change data to the Kafka topic;
[0026] Configuration module, used to configure synchronization rules;
[0027] The synchronization module is used to synchronize the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through the Flink job.
[0028] The system for real-time synchronization of MySQL data to Redis cache of the present invention is further improved in that:
[0029] Furthermore, the acquisition module includes:
[0030] The first reading module is used to install the Canal service on the server, configure Canal to connect to the MySQL database, and read the MySQL binlog log;
[0031] Parsing module, used by Canal to parse MySQL binlog logs, capture MySQL change data, and generate JSON format messages;
[0032] The sending module is used by Canal to send MySQL change data to the Kafka topic in JSON format.
[0033] Furthermore, the configuration module includes:
[0034] The second reading module is used to read the table and table field information of the MySQL data source, select the table steps to be synchronized, the fields to be synchronized in the table, and set the data filtering conditions;
[0035] Definition module, used to define the data format of Key and Value in Redis cache;
[0036] The storage module is used to store synchronization rules in a relational database for use by Flink jobs.
[0037] Furthermore, the synchronization module includes:
[0038] Create a module to create a Flink job, subscribe to Kafka topics, and read MySQL change data in real time;
[0039] The setting module is used to read the synchronization rules saved in the relational database after the Flink job is started, obtain the tables, fields, data filtering conditions and Redis data formats to be synchronized to the Redis cache, and set the Flink job to read the saved synchronization rules every hour;
[0040] The matching module is used to match the MySQL binlog data that needs to be synchronized according to the filtering conditions set in the synchronization rules;
[0041] The assembly module is used to call the Redis deletion interface to delete the cache when the operation type in the binlog data is DELETE; when the operation type in the binlog data is INSERT or UPDATE, assemble the Key and Value of the Redis data according to the Redis data format configured by the rule;
[0042] The calling module is used to call the Redis add data interface and send the assembled Redis data to the Redis service.
[0043] The present invention discloses a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, steps of a method for synchronizing MySQL data to a Redis cache in real time are implemented.
[0044] The present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for synchronizing MySQL data to Redis cache in real time are implemented.
[0045] The present invention has the following beneficial effects:
[0046] The method, system, device and medium for real-time synchronization of MySQL data to Redis cache of the present invention realize efficient, stable and flexible real-time synchronization of MySQL data to Redis cache by using Canal, Kafka and Flink technologies in specific operation. Specifically, by configuring the MySQL data to be synchronized and the Redis data format, it adapts to the requirements of different application scenarios. In addition, the binlog changes of MySQL are captured in real time by Canal, and the real-time transmission and processing of data are realized by Kafka and Flink, ensuring that the synchronization of data between MySQL and Redis has a high degree of real-time performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0048] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] In the description of the present invention, it should be understood that the terms “include” and “comprises” indicate the presence of described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.
[0051] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0052] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects are in an "or" relationship.
[0053] It should be understood that, although the terms first, second, third, etc. may be used to describe preset ranges, etc. in the embodiments of the present invention, these preset ranges should not be limited to these terms. These terms are only used to distinguish preset ranges from each other. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.
[0054] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0055] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention described and shown in the drawings here can usually be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0056] Various structural schematic diagrams of the embodiments disclosed in the present invention are shown in the accompanying drawings. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.
[0057] Embodiment 1
[0058] The method for real-time synchronization of MySQL data to Redis cache of the present invention comprises the following steps:
[0059] 1) Canal captures MySQL data changes, obtains MySQL change data, and sends the MySQL change data to the Kafka topic;
[0060] The specific process of step 1) is:
[0061] 11) Install and configure Canal;
[0062] Install the Canal service on the server, configure Canal to connect to the MySQL database, and read the MySQL binlog log to monitor MySQL data changes.
[0063] 12) Parse binlog;
[0064] Canal parses MySQL binlog logs, captures MySQL change data, and generates JSON format messages.
[0065] 13) Canal sends MySQL change data to the Kafka topic in JSON format.
[0066] 2) Configure synchronization rules;
[0067] 21) The user configures the MySQL data source in step 1) through the visualization page and connects to the MySQL data source.
[0068] 22) Read the table and table field information of the MySQL data source configured in step 21), and the user selects the table to be synchronized, the field to be synchronized in the table, and the set data filtering conditions on the visualization page.
[0069] 23) The user defines the data format of the Key (primary key) and Value (value) in the Redis cache on the page, for example, which fields does the Key consist of, which fields does the Value consist of, and what is the format of the Value (such as String, Hash, List, Set, etc.).
[0070] 24) Store user-defined synchronization rules in a relational database (such as MySQL) for use by Flink jobs.
[0071] 3) Create and start a Flink job;
[0072] 31) Create a Flink job, obtain the Kafka topic configured in step 1), and read the MySQL change data in real time.
[0073] 32) After the Flink job is started, it reads the synchronization rules saved in the relational database, obtains the tables, fields, data filtering conditions, and Redis data formats to be synchronized to the Redis cache, and sets the Flink job to read the saved synchronization rules every hour to ensure that the synchronization rules in the Flink job are the latest version.
[0074] 33) According to the filtering conditions set in the synchronization rules, match the MySQL binlog data that needs to be synchronized.
[0075] 34) When the operation type in the binlog data is "DELETE", the Redis deletion interface is called to delete the cache; when the operation type in the binlog data is "INSERT" or "UPDATE", the Key and Value of the Redis data are assembled according to the Redis data format configured by the rule.
[0076] 35) Call the Redis add data interface and send the assembled Redis data to the Redis service. The MySQL data completes the synchronization of the Redis cache.
[0077] Embodiment 2
[0078] The system for real-time synchronization of MySQL data to Redis cache of the present invention comprises:
[0079] The acquisition module is used for Canal to capture MySQL data changes, obtain MySQL change data, and send the MySQL change data to the Kafka topic;
[0080] Configuration module, used to configure synchronization rules;
[0081] The synchronization module is used to synchronize the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through the Flink job.
[0082] As an implementation manner of the present invention, the acquisition module includes:
[0083] The first reading module is used to install the Canal service on the server, configure Canal to connect to the MySQL database, and read the MySQL binlog log;
[0084] Parsing module, used by Canal to parse MySQL binlog logs, capture MySQL change data, and generate JSON format messages;
[0085] The sending module is used by Canal to send MySQL change data to the Kafka topic in JSON format.
[0086] As an implementation mode of the present invention, the configuration module includes:
[0087] The second reading module is used to read the table and table field information of the MySQL data source, select the table steps to be synchronized, the fields to be synchronized in the table, and set the data filtering conditions;
[0088] Definition module, used to define the data format of Key and Value in Redis cache;
[0089] The storage module is used to store synchronization rules in a relational database for use by Flink jobs.
[0090] As an implementation manner of the present invention, the synchronization module includes:
[0091] Create a module to create a Flink job, subscribe to Kafka topics, and read MySQL change data in real time;
[0092] The setting module is used to read the synchronization rules saved in the relational database after the Flink job is started, obtain the tables, fields, data filtering conditions and Redis data formats to be synchronized to the Redis cache, and set the Flink job to read the saved synchronization rules every hour;
[0093] The matching module is used to match the MySQL binlog data that needs to be synchronized according to the filtering conditions set in the synchronization rules;
[0094] The assembly module is used to call the Redis deletion interface to delete the cache when the operation type in the binlog data is DELETE; when the operation type in the binlog data is INSERT or UPDATE, assemble the Key and Value of the Redis data according to the Redis data format configured by the rule;
[0095] The calling module is used to call the Redis add data interface and send the assembled Redis data to the Redis service.
[0096] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0097] Embodiment 3
[0098] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for synchronizing MySQL data to Redis cache in real time are implemented, for example, including: Canal captures MySQL data changes, obtains MySQL change data, and sends the MySQL change data to a Kafka topic; configures synchronization rules; synchronizes the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through a Flink job, and the process of synchronizing the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through the Flink job is: create a Flink job, subscribe to the Kafka topic, read the MySQL change data in real time, and send the MySQL change data to the Redis cache. SQL changes data; after the Flink job is started, the synchronization rules saved in the relational database are read to obtain the tables, fields, data filtering conditions and Redis data formats to be synchronized to the Redis cache, and the Flink job is set to read the saved synchronization rules every hour; according to the filtering conditions set in the synchronization rules, the MySQL binlog data to be synchronized is matched; when the operation type in the binlog data is DELETE, the Redis deletion interface is called to delete the cache; when the operation type in the binlog data is INSERT or UPDATE, the Key and Value of the Redis data are assembled according to the Redis data format configured by the rule; the Redis add data interface is called to send the assembled Redis data to the Redis service. Among them, the memory may include a memory, such as a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk memory, etc.; the processor, the network interface, and the memory are interconnected through an internal bus, which can be an industrial standard architecture bus, a peripheral component interconnection standard bus, an extended industrial standard structure bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory is used to store programs. Specifically, the program can include program code, and the program code includes computer operation instructions. The memory may include memory and nonvolatile memory and provides instructions and data to the processor.
[0099] Embodiment 4
[0100] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the method for synchronizing MySQL data to Redis cache in real time are implemented, for example, including: Canal captures MySQL data changes, obtains MySQL change data, and sends the MySQL change data to a Kafka topic; configures synchronization rules; synchronizes the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through a Flink job. The process of synchronizing the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through the Flink job is: create a Flink job, subscribe to the Kafka topic, and read the MySQL change data in real time; after the Flink job is started, read the synchronization rules saved in the relational database, obtain the table, field, data filtering condition and Redis data format to be synchronized to the Redis cache, and set the Flink job to read the saved synchronization rules every hour; according to the filtering condition set in the synchronization rule, match the MySQL that needs to be synchronized binlog data; when the operation type in the binlog data is DELETE, the Redis deletion interface is called to delete the cache; when the operation type in the binlog data is INSERT or UPDATE, the Key and Value of the Redis data are assembled according to the Redis data format configured by the rules; the Redis add data interface is called to send the assembled Redis data to the Redis service. Specifically, the computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. The volatile memory may include random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include read-only memory (ROM), hard disk, flash memory, optical disk, magnetic disk, etc.
[0101] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0102] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0103] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0104] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0105] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and disclosure of the invention. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0106] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
[0107] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A method for real-time synchronization of MySQL data to Redis cache, characterized in that: include: Canal captures MySQL data changes, obtains MySQL change data, and sends the MySQL change data to the Kafka topic; Configure synchronization rules; Through the Flink job, the MySQL change data in the Kafka topic is synchronized to the Redis cache according to the synchronization rules.
2. The method for real-time synchronization of MySQL data to Redis cache according to claim 1, characterized in that: The process of the Canal capturing MySQL data changes, obtaining MySQL change data, and sending the MySQL change data to the Kafka topic is as follows: Install the Canal service on the server and configure Canal to connect to the MySQL database and read the MySQL binlog log; Canal parses MySQL binlog logs, captures MySQL change data, and generates JSON format messages; Canal sends MySQL change data to Kafka topics in JSON format.
3. The method for real-time synchronization of MySQL data to Redis cache according to claim 1, characterized in that: The process of configuring synchronization rules is as follows: Read the table and table field information of the MySQL data source, select the table to be synchronized, the field to be synchronized in the table, and set the data filtering conditions; Define the data format of Key and Value in Redis cache; Store synchronization rules in a relational database for use by Flink jobs.
4. The method for real-time synchronization of MySQL data to Redis cache according to claim 1, characterized in that: The process of synchronizing the MySQL change data in the Kafka topic to the Redis cache through the Flink job according to the synchronization rules is as follows: Create a Flink job, subscribe to the Kafka topic, and read MySQL change data in real time; After the Flink job is started, it reads the synchronization rules saved in the relational database, obtains the tables, fields, data filtering conditions, and Redis data formats to be synchronized to the Redis cache, and sets the Flink job to read the saved synchronization rules every hour. Match the MySQL binlog data that needs to be synchronized according to the filtering conditions set in the synchronization rules; When the operation type in the binlog data is DELETE, the Redis deletion interface is called to delete the cache; when the operation type in the binlog data is INSERT or UPDATE, the Key and Value of the Redis data are assembled according to the Redis data format configured by the rule; Call the Redis add data interface to send the assembled Redis data to the Redis service.
5. A system for real-time synchronization of MySQL data to Redis cache, characterized in that: include: The acquisition module is used for Canal to capture MySQL data changes, obtain MySQL change data, and send the MySQL change data to the Kafka topic; Configuration module, used to configure synchronization rules; The synchronization module is used to synchronize the MySQL change data in the Kafka topic to the Redis cache according to the synchronization rules through the Flink job.
6. The system for real-time synchronization of MySQL data to Redis cache according to claim 5, characterized in that: The acquisition module comprises: The first reading module is used to install the Canal service on the server, configure Canal to connect to the MySQL database, and read the MySQL binlog log; Parsing module, used by Canal to parse MySQL binlog logs, capture MySQL change data, and generate JSON format messages; The sending module is used by Canal to send MySQL change data to the Kafka topic in JSON format.
7. The system for real-time synchronization of MySQL data to Redis cache according to claim 5, characterized in that: The configuration module includes: The second reading module is used to read the table and table field information of the MySQL data source, select the table steps to be synchronized, the fields to be synchronized in the table, and set the data filtering conditions; Definition module, used to define the data format of Key and Value in Redis cache; The storage module is used to store synchronization rules in a relational database for use by Flink jobs.
8. The system for real-time synchronization of MySQL data to Redis cache according to claim 5, characterized in that: The synchronization module comprises: Create a module to create a Flink job, subscribe to Kafka topics, and read MySQL change data in real time; The setting module is used to read the synchronization rules saved in the relational database after the Flink job is started, obtain the tables, fields, data filtering conditions and Redis data formats to be synchronized to the Redis cache, and set the Flink job to read the saved synchronization rules every hour; The matching module is used to match the MySQL binlog data that needs to be synchronized according to the filtering conditions set in the synchronization rules; The assembly module is used to call the Redis deletion interface to delete the cache when the operation type in the binlog data is DELETE; when the operation type in the binlog data is INSERT or UPDATE, assemble the Key and Value of the Redis data according to the Redis data format configured by the rule; The calling module is used to call the Redis add data interface and send the assembled Redis data to the Redis service.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method for real-time synchronization of MySQL data to Redis cache as described in any one of claims 1 to 4 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, the steps of the method for real-time synchronization of MySQL data to Redis cache as described in any one of claims 1 to 4 are implemented.