CN113434525B - Cache data updating method and device, storage medium and electronic device - Google Patents

Cache data updating method and device, storage medium and electronic device Download PDF

Info

Publication number
CN113434525B
CN113434525B CN202110707341.2A CN202110707341A CN113434525B CN 113434525 B CN113434525 B CN 113434525B CN 202110707341 A CN202110707341 A CN 202110707341A CN 113434525 B CN113434525 B CN 113434525B
Authority
CN
China
Prior art keywords
database
cache data
identifier
data
updating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110707341.2A
Other languages
Chinese (zh)
Other versions
CN113434525A (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.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202110707341.2A priority Critical patent/CN113434525B/en
Publication of CN113434525A publication Critical patent/CN113434525A/en
Application granted granted Critical
Publication of CN113434525B publication Critical patent/CN113434525B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for updating cache data, a storage medium and an electronic device, wherein the method comprises the following steps: acquiring an operation log corresponding to a first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data; determining a first identifier corresponding to the first cache data according to the operation log, and determining whether second cache data corresponding to the first identifier exists in the second database; and under the condition that the second identification consistent with the first identification exists in the second database, updating the first cache data by the second cache data corresponding to the second identification in the second database. By adopting the technical scheme, the problems that in the related art, after the first database successfully updates data, if the operation is incorrect in the process of updating the data of the second database according to the data of the first database, the data of the first database is inconsistent with the data of the second database and the like are solved.

Description

Cache data updating method and device, storage medium and electronic device
Technical Field
The present invention relates to the field of communications, and in particular, to a method and apparatus for updating cache data, a storage medium, and an electronic device.
Background
Along with the progress of science and technology and the development of the internet, along with the rapid iteration of the APP version at the application end, the user quantity is gradually improved, the access quantity of the user is also increased, and in order to improve the performance of the APP, some hot data and some infrequently changed data, for example dictionary type data, are required to be put into a cache database to improve the performance of an interface, and in the process of inquiring target data, the specific operation steps are as follows: firstly, inquiring target data in a cache database, if the target data exist in the cache database, directly returning the target data to a user, if the target data do not exist in the cache database, firstly, inquiring the target data from a MYSQL database, and then, putting the target data into the cache database. However, there is a certain probability that the data in the cache database is changed, after the data is changed, the data in the cache database is also deleted at the same time when the MYSQL database is updated, but the operations of updating the MYSQL database and deleting the data in the cache database are two operations, if the operations are incorrect, the data in the cache database is inconsistent with the data in the MYSQL database, so that the experience of a user is affected.
Aiming at the problems that in the related art, after the first database successfully updates data, if the data of the first database is not consistent with the data of the second database due to improper operation in the process of updating the data of the second database, no effective solution has been proposed yet.
Disclosure of Invention
The embodiment of the invention provides a method and a device for updating cache data, a storage medium and an electronic device, which at least solve the problems that in the related art, after a first database successfully updates data, if incorrect operation can result in inconsistent data of the first database and the second database in the process of updating data of a second database according to the data of the first database.
According to an embodiment of the present invention, there is provided a method for updating cache data, including: acquiring an operation log corresponding to a first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data; determining a first identifier corresponding to the first cache data according to the operation log, and determining whether a second identifier consistent with the first identifier exists in a second database; and under the condition that the second database is determined to have the second identifier consistent with the first identifier, updating the first cache data by the second cache data corresponding to the second identifier in the second database.
In an exemplary embodiment, obtaining an operation log corresponding to the first database includes: under the condition that the first database receives an operation of updating third cache data, the first database is instructed to generate the operation log, wherein the third cache data is data before the first cache data is updated; and under the condition that the first database successfully generates the operation log, acquiring the operation log.
In an exemplary embodiment, in a case that it is determined that there is a second identifier in the second database that is consistent with the first identifier, after updating the first cache data with second cache data in the second database that corresponds to the second identifier, the method further includes: determining whether the second database successfully updates second cache data to the first cache data; and under the condition that the second database does not successfully update the second cache data into the first cache data, saving consumption information to a message queue corresponding to the second database, wherein the consumption information is used for indicating that the second cache data in the second database is updated into the first cache data.
In an exemplary embodiment, in case the second database does not successfully update the second cached data to the first cached data, after saving the consumption information to the message queue, the method further comprises: indicating the message queue to send the consumption message to the second database according to a preset mode; and under the condition that the consumption information sent by the information queue is received, updating the second cache data in the second database into the first cache data according to the consumption information.
In an exemplary embodiment, after determining whether the second database updates second cached data to the first cached data, the method further comprises: generating an update success identification under the condition that the second database is determined to successfully update the second cache data into the first cache data, wherein the update success identification is used for indicating that the second database successfully updates the second cache data into the first cache data; and sending the updating success identification to a page corresponding to the first database.
In an exemplary embodiment, determining, according to the operation log, a first identifier corresponding to the first cached data, and determining whether a second identifier consistent with the first identifier exists in a second database, includes: and deleting the operation log and sending prompt information to a page corresponding to the first database under the condition that the second database does not have the second identifier consistent with the first identifier, wherein the prompt information is used for indicating that the second database does not have the second identifier consistent with the first identifier.
According to another embodiment of the present invention, there is also provided an updating apparatus for caching data, including: the acquisition module is used for acquiring an operation log corresponding to the first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data; the determining module is used for determining a first identifier corresponding to the first cache data according to the operation log and determining whether a second identifier consistent with the first identifier exists in a second database or not; and the updating module is used for updating the first cache data by the second cache data corresponding to the second identifier in the second database under the condition that the second identifier consistent with the first identifier exists in the second database.
In an exemplary embodiment, the obtaining module is further configured to instruct, in a case where the first database receives an operation for updating third cached data, the first database to generate the operation log, where the third cached data is data before the first cached data performs the updating operation; and under the condition that the first database successfully generates the operation log, acquiring the operation log.
According to still another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium having a computer program stored therein, wherein the computer program is configured to perform the above-described method of updating cache data when run.
According to still another aspect of the embodiments of the present invention, there is further provided an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the above-mentioned method for updating cache data through the computer program.
In the embodiment of the invention, an operation log corresponding to a first database is obtained, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data; determining a first identifier corresponding to the first cache data according to the operation log, and determining whether second cache data corresponding to the first identifier exists in the second database; under the condition that the second identifier consistent with the first identifier exists in the second database, the second cache data corresponding to the second identifier in the second database is updated to the first cache data, namely, the first identifier corresponding to the first cache data is obtained through the operation log by obtaining the operation log corresponding to the first cache data after the first database is updated to the second cache data corresponding to the second identifier in the second database.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
FIG. 1 is a block diagram of a hardware configuration of a computer terminal of a method for updating cache data according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of updating cache data according to an embodiment of the invention;
FIG. 3 is a timing diagram of a method of updating cache data according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a method for updating cache data according to an embodiment of the present invention;
fig. 5 is a block diagram of an updating apparatus for buffering data according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The method embodiments provided by the embodiments of the present application may be performed in a computer terminal, or a similar computing device. Taking a computer terminal as an example, fig. 1 is a block diagram of a hardware structure of a computer terminal according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more (only one is shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a microprocessor MCU or a processing device such as a programmable logic device FPGA) and a memory 104 for storing data, and in one exemplary embodiment, may also include a transmission device 106 for communication functions and an input-output device 108. It will be appreciated by those skilled in the art that the configuration shown in fig. 1 is merely illustrative and is not intended to limit the configuration of the computer terminal described above. For example, a computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than the equivalent functions shown in FIG. 1 or more than the functions shown in FIG. 1.
The memory 104 may be used to store a computer program, for example, a software program of application software and a module, such as a computer program corresponding to a method for updating cache data in an embodiment of the present invention, and the processor 102 executes the computer program stored in the memory 104, thereby performing various functional applications and data processing, that is, implementing the method described above. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory remotely located relative to the processor 102, which may be connected to the computer terminal via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission means 106 is arranged to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, simply referred to as NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used to communicate with the internet wirelessly.
In this embodiment, a method for updating cache data is provided and applied to the computer terminal, and fig. 2 is a flowchart of a method for updating cache data according to an embodiment of the present invention, where the flowchart includes the following steps:
step S202, an operation log corresponding to a first database is obtained, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data;
step S204, determining a first identifier corresponding to the first cache data according to the operation log, and determining whether a second identifier consistent with the first identifier exists in a second database;
step S206, when it is determined that the second identifier consistent with the first identifier exists in the second database, updating the first cache data with the second cache data corresponding to the second identifier in the second database.
Through the steps, an operation log corresponding to the first database is obtained, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data; determining a first identifier corresponding to the first cache data according to the operation log, and determining whether second cache data corresponding to the first identifier exists in the second database; under the condition that the second identifier consistent with the first identifier exists in the second database, the second cache data corresponding to the second identifier in the second database is updated to the first cache data, namely, the first identifier corresponding to the first cache data is obtained through the operation log by obtaining the operation log corresponding to the first cache data after the first database is updated to the second cache data corresponding to the second identifier in the second database.
In an exemplary embodiment, the operation log includes: binlog, the first database comprising: the MYSQL database is fully called as a binary log, is a binary file and mainly records the operation log of the MYSQL database in the process of performing DML data operation language.
In an exemplary embodiment, in a case that the first database receives an operation of updating third cache data, the first database is instructed to generate the operation log, wherein the third cache data is data before the first cache data performs the update operation; and under the condition that the first database successfully generates the operation log, acquiring the operation log.
That is, when the target object updates the third cache data in the first database to the first cache data, the first database generates an operation log according to the operation of the target object for updating the third cache data in the first database, wherein the operation log is used for indicating the first cache data and the first identifier corresponding to the first cache data; acquiring an operation log under the condition that the target object is determined to successfully update the third cache data in the first database into the first cache data; and under the condition that the target object is determined to successfully update the third cache data in the first database to the first cache data, prohibiting the acquisition of the operation log.
In an exemplary embodiment, in a case that it is determined that a second identifier consistent with the first identifier exists in the second database, after updating the first cache data with second cache data corresponding to the second identifier in the second database, determining whether the second database successfully updates second cache data to the first cache data; and under the condition that the second database does not successfully update the second cache data into the first cache data, saving consumption information to a message queue corresponding to the second database, wherein the consumption information is used for indicating that the second cache data in the second database is updated into the first cache data.
In other words, after updating the first cache data with the second cache data corresponding to the second identifier in the second database, determining whether the second database successfully updates the second cache data with the first cache data, and returning an update success identifier to the moving display interface when determining that the second database successfully updates the second cache data with the first cache data; and under the condition that the second database does not successfully update the second cache data to the first cache data, generating consumption information, and placing the consumption information in a message list, wherein the message list can send the consumption information to the second database at regular time, and then compensation after the second cache data in the second database fails to update can be achieved.
In an exemplary embodiment, after storing consumption information in a message queue in a case that the second database does not successfully update second cache data into the first cache data, the message queue is instructed to send the consumption message to the second database in a preset manner; and under the condition that the consumption information sent by the information queue is received, updating the second cache data in the second database into the first cache data according to the consumption information.
Specifically, the message list may send consumption information to the second database at regular time, and the message queue sends consumption information to the second database according to a preset time interval, and updates the second cache data in the second database to the first cache data when the consumption information is received.
Further, under a preset condition, the message queue stops sending the consumption information, wherein the preset condition at least comprises one of the following: determining that second cache data in the second database is successfully updated to the first cache data; and reaching the preset sending times.
In an exemplary embodiment, after determining whether the second database updates second cache data to the first cache data, generating an update success flag in a case that it is determined that the second database successfully updates second cache data to the first cache data, wherein the update success flag is used for indicating that the second database successfully updates second cache data to the first cache data; and sending the updating success identification to a page corresponding to the first database.
That is, when it is determined that the second database successfully updates the second cache data to the first cache data, an update success identifier is generated, and the update success identifier is sent to a page corresponding to the first database for display, so that the target object determines that the second database successfully updates the second cache data to the first cache data according to the update success identifier.
In an exemplary embodiment, determining, according to the operation log, a first identifier corresponding to the first cached data, and determining whether a second identifier consistent with the first identifier exists in a second database, includes: and deleting the operation log and sending prompt information to a page corresponding to the first database under the condition that the second database does not have the second identifier consistent with the first identifier, wherein the prompt information is used for indicating that the second database does not have the second identifier consistent with the first identifier.
In other words, in the case that the third cache data of the first database is updated to the first cache data, it may be understood that whether the second identifier consistent with the first identifier exists in the second database is determined, or whether the second cache data consistent with the third cache data exists in the second database is also determined, in the case that the second cache data consistent with the third cache data does not exist in the second database, the second database does not perform the update operation, the operation log is deleted, and prompt information is sent to a page corresponding to the first database, so that the target object determines that the second identifier consistent with the first identifier does not exist in the second database according to the prompt information, and the second database may not perform the update operation.
In order to better understand the process of the method for updating the cache data, the following description is provided with reference to an optional embodiment to describe a flow of a method for implementing the update of the cache data, but the method is not limited to the technical scheme of the embodiment of the present invention.
In this embodiment, a method for updating cache data is provided, and fig. 3 is a timing chart of the method for updating cache data according to an embodiment of the present invention, as shown in fig. 3, specifically including the following steps:
step S301: the target object logs in to the H5 page (corresponding to the page in the above embodiment);
step S302: modifying first data (corresponding to third cache data in the above embodiment) in a MYSQL database (corresponding to the first database in the above embodiment) on the H5 page, and sending the modified second data (corresponding to the first cache data in the above embodiment) to a server;
step S303: updating the MYSQL database according to the modified second data;
step S304: after updating the MYSQL database, recording the corresponding binlog (corresponding to the operation log in the above embodiment);
step S305: sending the binlog log to a message service;
step S306: the message service updates the third data (corresponding to the second cache data in the above embodiment) in redis (corresponding to the second database in the above embodiment) according to the binlog log;
Step S307: the redis returns a message of successful update to the message service;
step S308: the message service returns a message of successful update to the server;
step S309: returning an update success identification to the server;
step S310: and displaying the page which is updated successfully to the target object.
Fig. 4 is a schematic diagram of a method for updating cache data according to an embodiment of the present invention, as shown in fig. 4, specifically as follows:
step S401: updating a MYSQL database by business service;
step S402: recording a binlog by using a MYSQL database;
step S403: subscribing binlog by the message service;
step S404: the first business extracts first data and a first identification of the first data in a binlog log;
step S405: the second service sends an update instruction to the redis, wherein the update instruction is used for indicating that second data corresponding to a second identifier consistent with the first identifier in the redis is updated to first data, and the updating is finished under the condition that the redis is successfully updated; in the case that the redis has not been updated successfully, step S406 is performed;
step S406: sending a consumption message to the RocketMQ (corresponding to the message queue in the embodiment), wherein the consumption message is used for indicating that second data corresponding to a second identifier consistent with the first identifier in redis is updated to first data;
It should be noted that this scheme is a compensation after the update failure of the redis cache by the retry mechanism of the lockmq.
Step S407: sending consumption information to a second service;
step S408: and sending consumption information to the redis to instruct the redis to update the second data to the first data again.
Through the embodiment, the operation log corresponding to the MYSQL database is obtained, wherein the operation log is used for indicating the updated first data and the first identifier corresponding to the first data; determining a first identifier corresponding to the first data according to the operation log, and determining whether second data corresponding to the first identifier exists in the Redis; under the condition that the second identifier consistent with the first identifier exists in the Redis, the first data is updated by the second data corresponding to the second identifier in the Redis, namely, the operation log corresponding to the cached data is obtained through the obtained MYSQL database, the first identifier corresponding to the first data is obtained through the operation log, and the first data is updated by the second data corresponding to the second identifier consistent with the first identifier in the Redis.
Through the embodiment, a power consumption request sent by a terminal is received, wherein the power consumption request is used for obtaining the total power consumption of target equipment in a preset time period; responding to the power consumption request, and acquiring a first total power consumption of the target equipment in a first state and a second total power consumption of the target equipment in a second state; and taking the sum of the first total power consumption and the second total power consumption as the total power consumption, namely determining the total power consumption according to the first total power consumption of the target equipment in the first state and the second total power consumption of the target equipment in the second state. By adopting the technical scheme, the problems that in the related technology, due to higher hardware module cost, the intelligent equipment can increase the overall cost of the intelligent equipment by increasing the power consumption of the hardware module sensing and calculating intelligent equipment and the like are solved, and the overall cost of the intelligent equipment is reduced.
From the description of the above embodiments, it will be clear to a person skilled in the art that the method according to the above embodiments may be implemented by means of software plus the necessary general hardware platform, but of course also by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method of the various embodiments of the present invention.
FIG. 5 is a block diagram of an update apparatus for buffering data according to an embodiment of the present invention; as shown in fig. 5, includes:
the obtaining module 52 is configured to obtain an operation log corresponding to the first database, where the operation log is used to indicate the updated first cache data and a first identifier corresponding to the first cache data;
a determining module 54, configured to determine, according to the operation log, a first identifier corresponding to the first cache data, and determine whether a second identifier consistent with the first identifier exists in a second database;
and the updating module 56 is configured to update the first cache data with second cache data corresponding to the second identifier in the second database if it is determined that the second identifier consistent with the first identifier exists in the second database.
Through the device, the operation log corresponding to the first database is obtained, wherein the operation log is used for indicating the updated first cache data and the first identifier corresponding to the first cache data; determining a first identifier corresponding to the first cache data according to the operation log, and determining whether second cache data corresponding to the first identifier exists in the second database; under the condition that the second identifier consistent with the first identifier exists in the second database, the second cache data corresponding to the second identifier in the second database is updated to the first cache data, namely, the first identifier corresponding to the first cache data is obtained through the operation log by obtaining the operation log corresponding to the first cache data after the first database is updated to the second cache data corresponding to the second identifier in the second database.
In an exemplary embodiment, the operation log includes: binlog, the first database comprising: the MYSQL database is fully called as a binary log, is a binary file and mainly records the operation log of the MYSQL database in the process of performing DML data operation language.
In an exemplary embodiment, the determining module is further configured to instruct, in a case where the first database receives an operation for updating third cached data, where the third cached data is data before the first cached data performs the updating operation, the first database to generate the operation log; and under the condition that the first database successfully generates the operation log, acquiring the operation log.
That is, when the target object updates the third cache data in the first database to the first cache data, the first database generates an operation log according to the operation of the target object for updating the third cache data in the first database, wherein the operation log is used for indicating the first cache data and the first identifier corresponding to the first cache data; acquiring an operation log under the condition that the target object is determined to successfully update the third cache data in the first database into the first cache data; and under the condition that the target object is determined to successfully update the third cache data in the first database to the first cache data, prohibiting the acquisition of the operation log.
In an exemplary embodiment, after determining that a second identifier consistent with the first identifier exists in the second database and updating second cached data corresponding to the second identifier in the second database to the first cached data, the determining module is further configured to determine whether the second database successfully updates second cached data to the first cached data; and under the condition that the second database does not successfully update the second cache data into the first cache data, saving consumption information to a message queue corresponding to the second database, wherein the consumption information is used for indicating that the second cache data in the second database is updated into the first cache data.
In other words, after updating the first cache data with the second cache data corresponding to the second identifier in the second database, determining whether the second database successfully updates the second cache data with the first cache data, and returning an update success identifier to the moving display interface when determining that the second database successfully updates the second cache data with the first cache data; and under the condition that the second database does not successfully update the second cache data to the first cache data, generating consumption information, and placing the consumption information in a message list, wherein the message list can send the consumption information to the second database at regular time, and then compensation after the second cache data in the second database fails to update can be achieved.
In an exemplary embodiment, after storing the consumption information to the message queue in case the second database does not successfully update the second cache data to the first cache data, the apparatus further includes: the receiving module is used for indicating the message queue to send the consumption message to the second database according to a preset mode; and under the condition that the consumption information sent by the information queue is received, updating the second cache data in the second database into the first cache data according to the consumption information.
Specifically, the message list may send consumption information to the second database at regular time, and the message queue sends consumption information to the second database according to a preset time interval, and updates the second cache data in the second database to the first cache data when the consumption information is received.
Further, under a preset condition, the message queue stops sending the consumption information, wherein the preset condition at least comprises one of the following: determining that second cache data in the second database is successfully updated to the first cache data; and reaching the preset sending times.
In an exemplary embodiment, the determining module is further configured to generate an update success identifier, where the update success identifier is used to indicate that the second database successfully updates the second cache data to the first cache data, if it is determined that the second database successfully updates the second cache data to the first cache data; and sending the updating success identification to a page corresponding to the first database.
That is, when it is determined that the second database successfully updates the second cache data to the first cache data, an update success identifier is generated, and the update success identifier is sent to a page corresponding to the first database for display, so that the target object determines that the second database successfully updates the second cache data to the first cache data according to the update success identifier.
In an exemplary embodiment, the determining module is further configured to delete the operation log and send a hint information to a page corresponding to the first database, where the hint information is used to indicate that a second identifier consistent with the first identifier does not exist in the second database, where the second identifier is determined that the second database does not exist in the second database.
In other words, in the case that the third cache data of the first database is updated to the first cache data, it may be understood that whether the second identifier consistent with the first identifier exists in the second database is determined, or whether the second cache data consistent with the third cache data exists in the second database is also determined, in the case that the second cache data consistent with the third cache data does not exist in the second database, the second database does not perform the update operation, the operation log is deleted, and prompt information is sent to a page corresponding to the first database, so that the target object determines that the second identifier consistent with the first identifier does not exist in the second database according to the prompt information, and the second database may not perform the update operation.
An embodiment of the present invention also provides a storage medium including a stored program, wherein the program executes the method of any one of the above.
Alternatively, in the present embodiment, the above-described storage medium may be configured to store program code for performing the steps of:
s1, acquiring an operation log corresponding to a first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data;
S2, determining a first identifier corresponding to the first cache data according to the operation log, and determining whether a second identifier consistent with the first identifier exists in a second database;
and S3, under the condition that the second identification consistent with the first identification exists in the second database, updating the first cache data by the second cache data corresponding to the second identification in the second database.
An embodiment of the invention also provides an electronic device comprising a memory having stored therein a computer program and a processor arranged to run the computer program to perform the steps of any of the method embodiments described above.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, where the transmission device is connected to the processor, and the input/output device is connected to the processor.
Alternatively, in the present embodiment, the above-described processor may be configured to execute the following steps by a computer program:
s1, acquiring an operation log corresponding to a first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data;
S2, determining a first identifier corresponding to the first cache data according to the operation log, and determining whether a second identifier consistent with the first identifier exists in a second database;
and S3, under the condition that the second identification consistent with the first identification exists in the second database, updating the first cache data by the second cache data corresponding to the second identification in the second database.
Alternatively, in the present embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Alternatively, specific examples in this embodiment may refer to examples described in the foregoing embodiments and optional implementations, and this embodiment is not described herein.
It will be appreciated by those skilled in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a memory device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than that shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps within them may be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (7)

1. A method for updating cache data, comprising:
acquiring an operation log corresponding to a first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data;
determining a first identifier corresponding to the first cache data according to the operation log, and determining whether a second identifier consistent with the first identifier exists in a second database;
updating second cache data corresponding to a second identifier in the second database under the condition that the second identifier consistent with the first identifier exists in the second database;
the method for obtaining the operation log corresponding to the first database comprises the following steps: under the condition that the first database receives an operation of updating third cache data, the first database is instructed to generate the operation log, wherein the third cache data is data before the first cache data is updated; under the condition that the first database successfully generates the operation log, acquiring the operation log;
Wherein, in the case that it is determined that a second identifier consistent with the first identifier exists in the second database, after updating the first cache data with second cache data corresponding to the second identifier in the second database, the method further includes: determining whether the second database successfully updates second cache data to the first cache data; and under the condition that the second database does not successfully update the second cache data into the first cache data, saving consumption information to a message queue corresponding to the second database, wherein the consumption information is used for indicating that the second cache data in the second database is updated into the first cache data.
2. The method for updating cached data according to claim 1, wherein in the case that the second database has not successfully updated second cached data to the first cached data, after saving the consumption information to the message queue, the method further comprises:
indicating the message queue to send the consumption information to the second database according to a preset mode;
and under the condition that consumption information sent by the message queue is received, updating second cache data in the second database into the first cache data according to the consumption information.
3. The method of updating cached data according to claim 1, wherein after determining whether the second database updates second cached data to the first cached data, the method further comprises:
generating an update success identification under the condition that the second database is determined to successfully update the second cache data into the first cache data, wherein the update success identification is used for indicating that the second database successfully updates the second cache data into the first cache data;
and sending the updating success identification to a page corresponding to the first database.
4. The method for updating cache data according to claim 1, wherein determining a first identifier corresponding to the first cache data according to the operation log, and determining whether a second identifier consistent with the first identifier exists in a second database, includes:
and deleting the operation log and sending prompt information to a page corresponding to the first database under the condition that the second database does not have the second identifier consistent with the first identifier, wherein the prompt information is used for indicating that the second database does not have the second identifier consistent with the first identifier.
5. An updating apparatus for cache data, comprising:
the acquisition module is used for acquiring an operation log corresponding to the first database, wherein the operation log is used for indicating updated first cache data and a first identifier corresponding to the first cache data;
the determining module is used for determining a first identifier corresponding to the first cache data according to the operation log and determining whether a second identifier consistent with the first identifier exists in a second database or not;
the updating module is used for updating the first cache data by second cache data corresponding to the second identifier in the second database under the condition that the second identifier consistent with the first identifier exists in the second database;
the obtaining module is further configured to instruct the first database to generate the operation log when the first database receives an operation of updating third cached data, where the third cached data is data before the first cached data performs the updating operation; under the condition that the first database successfully generates the operation log, acquiring the operation log;
the determining module is further configured to determine whether the second database successfully updates the second cached data to the first cached data; and under the condition that the second database does not successfully update the second cache data into the first cache data, saving consumption information to a message queue corresponding to the second database, wherein the consumption information is used for indicating that the second cache data in the second database is updated into the first cache data.
6. A computer readable storage medium, characterized in that the computer readable storage medium comprises a stored program, wherein the program when run performs the method of any of the preceding claims 1 to 4.
7. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method according to any of the claims 1-4 by means of the computer program.
CN202110707341.2A 2021-06-24 2021-06-24 Cache data updating method and device, storage medium and electronic device Active CN113434525B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110707341.2A CN113434525B (en) 2021-06-24 2021-06-24 Cache data updating method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110707341.2A CN113434525B (en) 2021-06-24 2021-06-24 Cache data updating method and device, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN113434525A CN113434525A (en) 2021-09-24
CN113434525B true CN113434525B (en) 2023-06-09

Family

ID=77754169

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110707341.2A Active CN113434525B (en) 2021-06-24 2021-06-24 Cache data updating method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN113434525B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117478535B (en) * 2023-12-26 2024-04-19 北京天空卫士网络安全技术有限公司 Log storage method and device

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101118509A (en) * 2007-09-12 2008-02-06 华为技术有限公司 Process, device and system for EMS memory data-base remote disaster tolerance
CN105574158A (en) * 2015-12-15 2016-05-11 广州品唯软件有限公司 Refreshing method and system of database caching data
CN107943841A (en) * 2017-10-30 2018-04-20 深圳前海微众银行股份有限公司 Stream data processing method, system and computer-readable recording medium
CN108345627A (en) * 2017-12-19 2018-07-31 海尔优家智能科技(北京)有限公司 The newer method, apparatus of local cache data, readable storage medium storing program for executing and equipment
CN108804237A (en) * 2017-05-05 2018-11-13 北京京东尚科信息技术有限公司 Data real-time statistical method, device, storage medium and electronic equipment
CN109788053A (en) * 2019-01-04 2019-05-21 深圳壹账通智能科技有限公司 Method of data synchronization and system
CN109871388A (en) * 2019-02-19 2019-06-11 北京字节跳动网络技术有限公司 Data cache method, device, whole electronic equipment and storage medium
CN110941623A (en) * 2019-11-12 2020-03-31 北京达佳互联信息技术有限公司 Data synchronization method and device
CN112615907A (en) * 2020-12-04 2021-04-06 北京齐尔布莱特科技有限公司 Data synchronization system and method
CN112749172A (en) * 2019-10-29 2021-05-04 深圳市茁壮网络股份有限公司 Data synchronization method and system between cache and database

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0308262D0 (en) * 2003-04-10 2003-05-14 Ibm Recovery from failures within data processing systems
US9342388B1 (en) * 2015-12-02 2016-05-17 International Business Machines Corporation Dynamic queue alias

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101118509A (en) * 2007-09-12 2008-02-06 华为技术有限公司 Process, device and system for EMS memory data-base remote disaster tolerance
CN105574158A (en) * 2015-12-15 2016-05-11 广州品唯软件有限公司 Refreshing method and system of database caching data
CN108804237A (en) * 2017-05-05 2018-11-13 北京京东尚科信息技术有限公司 Data real-time statistical method, device, storage medium and electronic equipment
CN107943841A (en) * 2017-10-30 2018-04-20 深圳前海微众银行股份有限公司 Stream data processing method, system and computer-readable recording medium
CN108345627A (en) * 2017-12-19 2018-07-31 海尔优家智能科技(北京)有限公司 The newer method, apparatus of local cache data, readable storage medium storing program for executing and equipment
CN109788053A (en) * 2019-01-04 2019-05-21 深圳壹账通智能科技有限公司 Method of data synchronization and system
CN109871388A (en) * 2019-02-19 2019-06-11 北京字节跳动网络技术有限公司 Data cache method, device, whole electronic equipment and storage medium
CN112749172A (en) * 2019-10-29 2021-05-04 深圳市茁壮网络股份有限公司 Data synchronization method and system between cache and database
CN110941623A (en) * 2019-11-12 2020-03-31 北京达佳互联信息技术有限公司 Data synchronization method and device
CN112615907A (en) * 2020-12-04 2021-04-06 北京齐尔布莱特科技有限公司 Data synchronization system and method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"Age of Information Driven Cache Content Update Scheduling for Dynamic Contents in Heterogeneous Networks";Manyou Ma 等;《IEEE TRANSACTIONS ON WIRELESS COMMUNICATIONS》;第8427-8441页 *
"分布式数据流计算系统的 数据缓存技术综述";袁旭初 等;《大数据》;第101-116页 *

Also Published As

Publication number Publication date
CN113434525A (en) 2021-09-24

Similar Documents

Publication Publication Date Title
CN102271327A (en) Method and equipment for indicating software version updating
JP2009246983A (en) Method, software and apparatus for performing actions on wireless device using action lists and versioning
CN111142905B (en) OTA upgrading method, OTA server and OTA upgrading system
CN101854623B (en) System and method for remote upgrade of M2M terminal
CN105357031A (en) OTA (over the air) upgrade method and device
CN106850241A (en) A kind of vehicle-mounted OBD terminals and its remote upgrade method
CN102036224A (en) Method, system and upgrading control entity for informing mobile equipment of upgrading software
CN106412092A (en) Message pushing method, message pushing device and server
CN111125175A (en) Service data query method and device, storage medium and electronic device
CN112596768B (en) Updating method and device of equipment, storage medium and electronic device
CN113434293A (en) Method and apparatus for processing repeat request, storage medium, and electronic apparatus
CN110543324A (en) Plug-in increment updating method and device for application program
CN105530630B (en) A kind of OTA upgrade method and equipment
CN113434525B (en) Cache data updating method and device, storage medium and electronic device
WO2003088689A1 (en) Simultaneous nationwide update of database information on mobile communications devices
EP3506599B1 (en) Method for synchronizing contact information, apparatus and medium
CN114095876A (en) Broadcast data processing method and device, storage medium and electronic device
CN101877071A (en) Data updating method, device and system
CN102665181B (en) Software updating method based on USSD and a system thereof
CN105227600A (en) The method of mobile device system upgrading
CN113190565B (en) Data updating method and device, storage medium and electronic device
CN105872106A (en) Over-the-air upgrade method, over-the-air server and terminal
US20130145013A1 (en) Communication terminal and content update method
JP6871975B2 (en) Communication control device and communication setting method
CN114466387A (en) Method and device for updating configuration file of base station, storage medium and electronic device

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