CN113434525A - 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
CN113434525A
CN113434525A CN202110707341.2A CN202110707341A CN113434525A CN 113434525 A CN113434525 A CN 113434525A CN 202110707341 A CN202110707341 A CN 202110707341A CN 113434525 A CN113434525 A CN 113434525A
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.)
Granted
Application number
CN202110707341.2A
Other languages
Chinese (zh)
Other versions
CN113434525B (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 cache data updating method and device, 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 a second database; and under the condition that the second identifier which is consistent with the first identifier exists in the second database, updating the second cache data which is corresponding to the second identifier in the second database with the first cache data. By adopting the technical scheme, the problems that in the related art, after the data of the first database is successfully updated, the data of the second database is updated according to the data of the first database, if the data of the first database is not consistent with the data of the second database due to improper operation, 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 an apparatus for updating cache data, a storage medium, and an electronic apparatus.
Background
With the progress of scientific technology and the development of internet, along with the quick iteration of the APP version of the application end, the functions are continuously improved, the user amount is gradually increased, the access amount of the user is also increased, in order to improve the performance of the APP, some hot data and some data which are not frequently changed, such as dictionary type data, need to be put into a cache database to improve the performance of an interface, and in the process of inquiring target data, specific operation steps are as follows: firstly, inquiring target data in a cache database, if the target data exists in the cache database, directly returning the target data to a user, and if the target data does not exist in the cache database, firstly inquiring the target data from the MYSQL database, and then putting the target data into the cache database. However, data in the cache database is changed at a certain probability, after the data is changed, the MYSQL database needs to be updated, and the data in the cache database needs to be deleted, but updating the MYSQL database and deleting the data in the cache database are two operations, and if the operations are improper, the data in the cache database is inconsistent with the data in the MYSQL database, so that user experience is affected.
In the related art, no effective solution is provided for the problems that in the process of updating the data of the second database according to the data of the first database after the data of the first database is successfully updated, if the data of the first database is inconsistent with the data of the second database due to improper operation, and the like.
Disclosure of Invention
The embodiment of the invention provides a cache data updating method and device, a storage medium and an electronic device, which are used for at least solving the problems that in the related art, after a first database successfully updates data, data of a second database is updated according to the data of the first database, if the data of the first database is not consistent with the data of the second database due to improper operation, and the like.
According to an embodiment of the present invention, a method for updating cache data is provided, 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 updating second cache data corresponding to the second identifier in the second database with the first cache data under the condition that the second identifier which is consistent with the first identifier exists 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 are data of the first cache data before the updating operation is executed; and acquiring the operation log under the condition that the first database successfully generates the operation log.
In an exemplary embodiment, after determining that there is a second identifier in the second database that is consistent with the first identifier, the method further includes, after updating the first cached data with second cached 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, after saving the consumption information to the message queue in case that the second database does not successfully update the second cache data to the first cache data, the method further comprises: instructing the message queue to send the consumption message to the second database according to a preset mode; and under the condition of receiving the consumption message sent by the message queue, updating the second cache data in the second database into the first cache data according to the consumption message.
In one exemplary embodiment, after determining whether the second database updates the second cached data to the first cached data, the method further comprises: under the condition that the second database is determined to be successful in updating second cache data into the first cache data, generating an update success identifier, wherein the update success identifier is used for indicating that the second database is successful in updating the second cache data into the first cache data; and sending the update 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 under the condition that it is determined that a second identifier which is consistent with the first identifier does not exist in the second database, deleting the operation log, and sending prompt information to a page corresponding to the first database, wherein the prompt information is used for indicating that the second identifier which is consistent with the first identifier does not exist in the second database.
According to another embodiment of the present invention, there is provided an updating apparatus for cache data, including: the acquisition module is used for 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; 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; and the updating module is used for updating second cache data corresponding to the second identifier in the second database with the first cache data under the condition that the second identifier which is consistent with the first identifier exists in the second database.
In an exemplary embodiment, 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 cache data, where the third cache data is data of the first cache data before the updating operation is performed; and acquiring the operation log under the condition that the first database successfully generates the operation log.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the above-mentioned cache data updating method when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in 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 a second database; updating the first cache data with second cache data corresponding to the second identifier in the second database in case of determining that the second identifier consistent with the first identifier exists in the second database, by acquiring an operation log corresponding to the first database after the cache data is updated, acquiring a first identifier corresponding to the first cache data through the operation log, and updating the first cache data with second cache data corresponding to a second identifier in the second database, which is consistent with the first identifier, in the process of updating the data of the second database according to the data of the first database after the first database successfully updates the data, if improper operation can cause the problem that the data of the first database is inconsistent with the data of the second database, and the like, the problem that the data of the first database is inconsistent with the data of the second database can be avoided by adopting a subscription operation log mode.
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 embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware structure of a computer terminal of an update method of cache data according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for updating cached data according to an embodiment of the present invention;
FIG. 3 is a timing diagram of a method for updating cached data according to an embodiment of the invention;
FIG. 4 is a diagram illustrating a method for updating cached data according to an embodiment of the present invention;
fig. 5 is a block diagram of an updating apparatus for cache data according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or 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 provided by the embodiment of the application can be executed in a computer terminal, a computer terminal or a similar operation device. Taking the example of running on a computer terminal, fig. 1 is a hardware structure block diagram of a computer terminal of an updating method of cache data according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more (only one shown in fig. 1) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, and in an exemplary embodiment, may also include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the computer terminal. For example, the computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration with equivalent functionality to that shown in FIG. 1 or with more functionality than that shown in FIG. 1.
The memory 104 may be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the method for updating the cache data in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, so as to implement the above-mentioned method. The 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 located remotely from the processor 102, which may be connected to a computer terminal over 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 device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In this embodiment, a method for updating cache data is provided, which is applied to the computer terminal described above, 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, obtaining 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;
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, if it is determined that a second identifier consistent with the first identifier exists in the second database, updating the first cache data with 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 the 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 a second database; updating the first cache data with second cache data corresponding to the second identifier in the second database in case of determining that the second identifier consistent with the first identifier exists in the second database, by acquiring an operation log corresponding to the first database after the cache data is updated, acquiring a first identifier corresponding to the first cache data through the operation log, and updating the first cache data with second cache data corresponding to a second identifier in the second database, which is consistent with the first identifier, in the process of updating the data of the second database according to the data of the first database after the first database successfully updates the data, if improper operation can cause the problem that the data of the first database is inconsistent with the data of the second database, and the like, the problem that the data of the first database is inconsistent with the data of the second database can be avoided by adopting a subscription operation log mode.
In one exemplary embodiment, the operation log includes: binlog log, the first database comprising: the MYSQL database is a binary file, and the Binlog is called as binary log, and mainly records the operation log of the MYSQL database in the DML data operation language process.
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 of the first cache data before the update operation is performed; and acquiring the operation log under the condition that the first database successfully generates the operation log.
That is to say, when the target object updates the third cached data in the first database to the first cached data, the first database generates an operation log according to an operation of the target object to update the third cached data in the first database, where the operation log is used to indicate the first cached data and a first identifier corresponding to the first cached data; 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, obtaining an operation log; and in the case that the target object is determined to successfully update the third cache data in the first database into the first cache data, the operation log is prohibited from being acquired.
In an exemplary embodiment, after determining that a second identifier consistent with the first identifier exists in the second database, updating second cache data corresponding to the second identifier in the second database with the first cache data, determining whether the second database successfully updates the 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 the first cache data is updated by the second cache data corresponding to the second identifier in the second database, determining whether the second database successfully updates the first cache data by the second cache data, and returning an update success identifier to the moving display interface when it is determined that the second database successfully updates the first cache data by the second cache data; and under the condition that the second database is determined not to successfully update the first cache data with the second 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, namely, compensation can be achieved after the second cache data in the second database fails to be updated.
In an exemplary embodiment, in the case that the second database does not successfully update the second cache data to the first cache data, after saving the consumption information to a message queue, instructing the message queue to send the consumption message to the second database in a preset manner; and under the condition of receiving the consumption message sent by the message queue, updating the second cache data in the second database into the first cache data according to the consumption message.
Specifically, the message list may send consumption information to the second database at regular time, the message queue sends consumption information to the second database according to a preset time interval, and the second cache data in the second database is updated 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 conditions: determining that second cache data in the second database is successfully updated to the first cache data; reaching the preset sending times.
In an exemplary embodiment, after determining whether the second database updates the second cached data to the first cached data, in case that it is determined that the second database successfully updates the second cached data to the first cached data, generating an update success identifier, wherein the update success identifier is used for indicating that the second database successfully updates the second cached data to the first cached data; and sending the update success identification to a page corresponding to the first database.
That is to say, under the condition that 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 under the condition that it is determined that a second identifier which is consistent with the first identifier does not exist in the second database, deleting the operation log, and sending prompt information to a page corresponding to the first database, wherein the prompt information is used for indicating that the second identifier which is consistent with the first identifier does not exist in the second database.
In other words, when the third cached data in the first database is updated to the first cached data, it may be determined whether a second identifier consistent with the first identifier exists in the second database, or it may be determined whether a second cached data consistent with the third cached data exists in the second database, and when the second cached data consistent with the third cached data does not exist in the second database, the second database does not perform the update operation, deletes the operation log, and sends the prompt information to the 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 above-mentioned cache data updating method, the following describes a flow of the above-mentioned cache data updating implementation method with reference to an optional embodiment, but the technical solution of the embodiment of the present invention is not limited thereto.
In this embodiment, a method for updating cache data is provided, and fig. 3 is a timing diagram of a method for updating cache data according to an embodiment of the present invention, as shown in fig. 3, the following steps are specifically provided:
step S301: target object login H5 page (equivalent 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 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 the MYSQL database is updated, a corresponding binlog log (equivalent to the operation log in the embodiment) is recorded;
step S305: sending the binlog log to a messaging service;
step S306: the message service updates third data (equivalent to the second cache data in the above embodiment) in redis (equivalent 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 updating success identifier to the server;
step S310: and displaying the page with the successful update to the target object.
Fig. 4 is a schematic diagram of an updating method of cache data according to an embodiment of the present invention, as shown in fig. 4, the following details are provided:
step S401: the business service updates the MYSQL database;
step S402: the MYSQL database records binlog logs;
step S403: the message service subscribes to the binlog log;
step S404: the first service extracts first data and a first identifier of the first data from a binlog log;
step S405: the second service sends an update indication to the redis, wherein the update indication is used for indicating that second data corresponding to a second identifier consistent with the first identifier in the redis is updated to be first data, and the update is finished under the condition that the redis is updated successfully; in the case where the update of the redis is not successful, step S406 is performed;
step S406: sending a consumption message to a RockettMQ (corresponding to a message queue in the above embodiment), wherein the consumption message is used for indicating that second data corresponding to a second identifier in the redis, which is consistent with the first identifier, is updated to the first data;
it should be noted that this scheme is to compensate for the failure of the redis cache update by the retry mechanism of the rockmq.
Step S407: sending consumption information to the second service;
step S408: and sending consumption information to the redis to instruct the redis to renew the second data into the first data.
By 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 Redis; under the condition that a second identifier consistent with the first identifier exists in Redis, updating first data of second data corresponding to the second identifier in Redis, namely, acquiring an operation log corresponding to a MYSQL database after cache data is updated, acquiring a first identifier corresponding to the first data through the operation log, and updating the first data of second data corresponding to the second identifier consistent with the first identifier in Redis.
Through the embodiment, a power consumption request sent by a terminal is received, wherein the power consumption request is used for acquiring the total power consumption of target equipment in a preset time period; responding to the power consumption request, and acquiring first total power consumption of the target equipment in a first state and second total power consumption of the target equipment in a second state; and taking the sum of the first total electricity consumption and the second total electricity consumption as the total electricity consumption, namely determining the total electricity consumption according to the first total electricity consumption of the target equipment in the first state and the second total electricity consumption of the target equipment in the second state. By adopting the technical scheme, the problems that in the related technology, the cost of the hardware module is higher, the whole cost of the intelligent equipment can be increased by the intelligent equipment through increasing the power consumption of the hardware module sensing and calculating the intelligent equipment, and the like are solved, and the whole cost of the intelligent equipment is reduced.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Fig. 5 is a block diagram of a structure of an updating apparatus for cache data according to an embodiment of the present invention; as shown in fig. 5, includes:
an obtaining module 52, configured to obtain an operation log corresponding to a 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;
an updating module 56, configured to update the first cache data with second cache data in the second database corresponding to the second identifier if it is determined that a second identifier that is consistent with the first identifier exists in the second database.
By the device, an operation log corresponding to the first database is obtained, wherein the operation log is used for indicating the 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 a second database; updating the first cache data with second cache data corresponding to the second identifier in the second database in case of determining that the second identifier consistent with the first identifier exists in the second database, by acquiring an operation log corresponding to the first database after the cache data is updated, acquiring a first identifier corresponding to the first cache data through the operation log, and updating the first cache data with second cache data corresponding to a second identifier in the second database, which is consistent with the first identifier, in the process of updating the data of the second database according to the data of the first database after the first database successfully updates the data, if improper operation can cause the problem that the data of the first database is inconsistent with the data of the second database, and the like, the problem that the data of the first database is inconsistent with the data of the second database can be avoided by adopting a subscription operation log mode.
In one exemplary embodiment, the operation log includes: binlog log, the first database comprising: the MYSQL database is a binary file, and the Binlog is called as binary log, and mainly records the operation log of the MYSQL database in the DML data operation language process.
In an exemplary embodiment, the determining 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 of the first cached data before the updating operation is performed; and acquiring the operation log under the condition that the first database successfully generates the operation log.
That is to say, when the target object updates the third cached data in the first database to the first cached data, the first database generates an operation log according to an operation of the target object to update the third cached data in the first database, where the operation log is used to indicate the first cached data and a first identifier corresponding to the first cached data; 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, obtaining an operation log; and in the case that the target object is determined to successfully update the third cache data in the first database into the first cache data, the operation log is prohibited from being acquired.
In an exemplary embodiment, after determining that there is a second identifier in the second database that is consistent with the first identifier, updating the first cached data with second cached data in the second database that corresponds to the second identifier, the determining module is further configured to determine whether the second database successfully updates the second cached data with 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 the first cache data is updated by the second cache data corresponding to the second identifier in the second database, determining whether the second database successfully updates the first cache data by the second cache data, and returning an update success identifier to the moving display interface when it is determined that the second database successfully updates the first cache data by the second cache data; and under the condition that the second database is determined not to successfully update the first cache data with the second 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, namely, compensation can be achieved after the second cache data in the second database fails to be updated.
In an exemplary embodiment, after saving the consumption information to the message queue in a case that 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 of receiving the consumption message sent by the message queue, updating the second cache data in the second database into the first cache data according to the consumption message.
Specifically, the message list may send consumption information to the second database at regular time, the message queue sends consumption information to the second database according to a preset time interval, and the second cache data in the second database is updated 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 conditions: determining that second cache data in the second database is successfully updated to the first cache data; reaching the preset sending times.
In an exemplary embodiment, the determining module is further configured to generate an update success identifier if it is determined that the second database successfully updates the second cached data to the first cached data, where the update success identifier is used to indicate that the second database successfully updates the second cached data to the first cached data; and sending the update success identification to a page corresponding to the first database.
That is to say, under the condition that 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, in a case that it is determined that a second identifier that is consistent with the first identifier does not exist in the second database, delete the operation log, and send prompt information to a page corresponding to the first database, where the prompt information is used to indicate that a second identifier that is consistent with the first identifier does not exist in the second database.
In other words, when the third cached data in the first database is updated to the first cached data, it may be determined whether a second identifier consistent with the first identifier exists in the second database, or it may be determined whether a second cached data consistent with the third cached data exists in the second database, and when the second cached data consistent with the third cached data does not exist in the second database, the second database does not perform the update operation, deletes the operation log, and sends the prompt information to the 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 further provides a storage medium including a stored program, wherein the program executes any one of the methods described above.
Alternatively, in the present embodiment, the storage medium may be configured to store program codes for performing the following steps:
s1, obtaining an operation log corresponding to the first database, wherein the operation log is used for indicating the 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;
s3, if it is determined that the second database has a second identifier that is consistent with the first identifier, updating the first cache data with second cache data in the second database that corresponds to the second identifier.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, obtaining an operation log corresponding to the first database, wherein the operation log is used for indicating the 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;
s3, if it is determined that the second database has a second identifier that is consistent with the first identifier, updating the first cache data with second cache data in the second database that corresponds to the second identifier.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing program codes, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

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;
and updating second cache data corresponding to the second identifier in the second database with the first cache data under the condition that the second identifier which is consistent with the first identifier exists in the second database.
2. The method for updating the cache data according to claim 1, wherein obtaining the operation log corresponding to the first database comprises:
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 are data of the first cache data before the updating operation is executed;
and acquiring the operation log under the condition that the first database successfully generates the operation log.
3. The method for updating cached data according to claim 1, wherein after determining that a second identifier consistent with the first identifier exists in the second database, updating the first cached data with second cached data in the second database corresponding to the second identifier, the method further comprises:
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.
4. The method for updating cached data as claimed in claim 3, wherein in case that 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:
instructing the message queue to send the consumption message to the second database according to a preset mode;
and under the condition of receiving the consumption message sent by the message queue, updating the second cache data in the second database into the first cache data according to the consumption message.
5. The method for updating cached data as claimed in claim 3, wherein after determining whether the second database updates the second cached data to the first cached data, the method further comprises:
under the condition that the second database is determined to be successful in updating second cache data into the first cache data, generating an update success identifier, wherein the update success identifier is used for indicating that the second database is successful in updating the second cache data into the first cache data;
and sending the update success identification to a page corresponding to the first database.
6. The method for updating the 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 comprises:
and under the condition that it is determined that a second identifier which is consistent with the first identifier does not exist in the second database, deleting the operation log, and sending prompt information to a page corresponding to the first database, wherein the prompt information is used for indicating that the second identifier which is consistent with the first identifier does not exist in the second database.
7. An apparatus for updating cache data, comprising:
the acquisition module is used for 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;
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;
and the updating module is used for updating second cache data corresponding to the second identifier in the second database with the first cache data under the condition that the second identifier which is consistent with the first identifier exists in the second database.
8. The apparatus for updating cache data according to claim 7, comprising:
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 cache data, where the third cache data is data of the first cache data before the updating operation is performed; and acquiring the operation log under the condition that the first database successfully generates the operation log.
9. A computer-readable storage medium, comprising a stored program, wherein the program is operable to perform the method of any one of claims 1 to 6.
10. 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 of any of claims 1 to 6 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 true CN113434525A (en) 2021-09-24
CN113434525B 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)

Cited By (1)

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

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040215998A1 (en) * 2003-04-10 2004-10-28 International Business Machines Corporation Recovery from failures within data processing systems
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
US20170161126A1 (en) * 2015-12-02 2017-06-08 International Business Machines Corporation Dynamic queue alias
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

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040215998A1 (en) * 2003-04-10 2004-10-28 International Business Machines Corporation Recovery from failures within data processing systems
CN101118509A (en) * 2007-09-12 2008-02-06 华为技术有限公司 Process, device and system for EMS memory data-base remote disaster tolerance
US20170161126A1 (en) * 2015-12-02 2017-06-08 International Business Machines Corporation Dynamic queue alias
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
MANYOU MA 等: ""Age of Information Driven Cache Content Update Scheduling for Dynamic Contents in Heterogeneous Networks"", 《IEEE TRANSACTIONS ON WIRELESS COMMUNICATIONS》 *
袁旭初 等: ""分布式数据流计算系统的 数据缓存技术综述"", 《大数据》 *

Cited By (2)

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

Also Published As

Publication number Publication date
CN113434525B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
CN111372249B (en) System and method for testing consistency of code number downloading process of eSIM (embedded subscriber identity Module) terminal of Internet of things
CN106412092A (en) Message pushing method, message pushing device and server
CN111142905A (en) OTA (over-the-air) upgrading method, OTA server and OTA upgrading system
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
CN103973745A (en) Mobile terminal operating system updating method and device
CN105530630B (en) A kind of OTA upgrade method and equipment
CN100428824C (en) Method for carrying out active inquiry maintenance on mobile terminal
CN113434525B (en) Cache data updating method and device, storage medium and electronic device
CN113190565B (en) Data updating method and device, storage medium and electronic device
CN113518317B (en) Method and device for sending prompt information, storage medium and electronic device
CN113434135B (en) Method and device for determining call repeatability of interface, storage medium and electronic device
CN115905280A (en) Mobile phone number attribution operator query method, device, storage medium and equipment
CN114466387A (en) Method and device for updating configuration file of base station, storage medium and electronic device
CN111427603B (en) Application program upgrading method and device
CN113434171A (en) Resource package updating method and device, storage medium and electronic device
US20130145013A1 (en) Communication terminal and content update method
EP3758396B1 (en) Communication control device, communication setting method, communication setting program, and communication system
CN113852919B (en) Method and device for generating early warning message, storage medium and electronic device
CN113873533B (en) Data processing method, device, equipment and storage medium
CN114090917A (en) City information display method and device, storage medium and electronic device
CN114697375B (en) Voice packet switching method and device, storage medium and electronic device
CN113194523B (en) Network connection establishing method, device, terminal and storage medium
CN112506580A (en) Data fusion method and device, 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