WO2024066001A1 - Data update method and apparatus, storage medium, and electronic apparatus - Google Patents

Data update method and apparatus, storage medium, and electronic apparatus Download PDF

Info

Publication number
WO2024066001A1
WO2024066001A1 PCT/CN2022/134785 CN2022134785W WO2024066001A1 WO 2024066001 A1 WO2024066001 A1 WO 2024066001A1 CN 2022134785 W CN2022134785 W CN 2022134785W WO 2024066001 A1 WO2024066001 A1 WO 2024066001A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
database
cache
update
time
Prior art date
Application number
PCT/CN2022/134785
Other languages
French (fr)
Chinese (zh)
Inventor
唐永将
Original Assignee
海尔优家智能科技(北京)有限公司
青岛海尔科技有限公司
海尔智家股份有限公司
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 海尔优家智能科技(北京)有限公司, 青岛海尔科技有限公司, 海尔智家股份有限公司 filed Critical 海尔优家智能科技(北京)有限公司
Publication of WO2024066001A1 publication Critical patent/WO2024066001A1/en

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
    • 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/23Updating
    • G06F16/2308Concurrency control

Definitions

  • the present disclosure relates to the field of smart home technology, and in particular to a data updating method, device, storage medium and electronic device.
  • the process of data access is generally that users concurrently access the data of the business system, and the system returns response information.
  • the process of data access is generally that users concurrently access the data of the business system, and the system returns response information.
  • the process of data access is generally that users concurrently access the data of the business system, and the system returns response information.
  • the process of data access is generally that users concurrently access the data of the business system, and the system returns response information.
  • the process of data access is generally that users concurrently access the data of the business system, and the system returns response information.
  • the process of data access is generally that users concurrently access the data of the business system, and the system returns response information.
  • the embodiments of the present disclosure provide a data updating method, device, storage medium and electronic device to at least solve the technical problem in the related art of how to update cache data to ensure that the data in the database is consistent with the cache data.
  • a data updating method including: obtaining an update identifier corresponding to log content of a first database, the update identifier being used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that first data in the first database is changed to second data, obtaining the second data from the first database, wherein the first data and the second data correspond to the same data identifier; determining the first data stored in a cache, and updating the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
  • a data updating device including: a first updating module, configured to obtain an update identifier corresponding to the log content of a first database, wherein the update identifier is used to indicate whether the log content of the first database is updated; an obtaining module, configured to obtain the second data from the first database when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, wherein the first data and the second data correspond to the same data identifier; a second updating module, configured to determine the first data stored in a cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
  • a computer-readable storage medium in which a computer program is stored, wherein the computer program is configured to execute the above data updating method when running.
  • an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the data updating method through the computer program.
  • an update identifier corresponding to the log content of the first database is obtained, and the update identifier is used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that the first data in the first database is changed to, wherein the second data corresponds to the same data identifier as the first data, the second data is obtained from the first database; the first data stored in the cache is determined, and the first data stored in the cache is updated to the second data, wherein the cache and the first database have pre-synchronized the first data.
  • FIG1 is a hardware structure block diagram of a computer terminal of a method for determining an intention instruction according to an embodiment of the present application
  • FIG2 is a schematic diagram of a hardware environment of a data updating method according to an embodiment of the present disclosure
  • FIG3 is a flow chart of a data updating method according to an embodiment of the present disclosure.
  • FIG4 is a flow chart of a data updating method according to an embodiment of the present disclosure.
  • FIG5 is a schematic diagram of a data updating method according to an embodiment of the present disclosure.
  • FIG6 is a schematic diagram of a method for updating data without caching according to an embodiment of the present disclosure.
  • FIG7 is a flow chart of a method for updating data with cache according to an embodiment of the present disclosure (I);
  • FIG8 is a flow chart of a method for updating data with cache according to an embodiment of the present disclosure (II);
  • FIG9 is a flow chart of a method for updating data with cache according to an embodiment of the present disclosure (III);
  • FIG. 10 is a structural block diagram of a data updating device according to an embodiment of the present disclosure.
  • FIG. 1 is a hardware structure block diagram of a computer terminal of a method for determining an intention instruction in an embodiment of the present application.
  • the computer terminal may include one or more (only one is shown in FIG. 1 ) processors 202 (the processor 202 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 204 for storing data.
  • the above-mentioned computer terminal may also include a transmission device 106 and an input and output device 108 for communication functions.
  • FIG. 1 is only for illustration, and it does not limit the structure of the above-mentioned computer terminal.
  • the computer terminal may also include more or fewer components than those shown in FIG. 1 , or have different configurations with equivalent functions as shown in FIG. 1 or more functions than those shown in FIG. 1 .
  • the memory 204 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the determination method of the intention instruction in the embodiment of the present application.
  • the processor 202 executes various functional applications and data processing by running the computer program stored in the memory 204, that is, to implement the above method.
  • the memory 204 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
  • the memory 204 may further include a memory remotely arranged relative to the processor 202, and these remote memories can be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
  • the transmission device 106 is used to receive or send data via a network.
  • the specific example of the above network may include a wireless network provided by a communication provider of a computer terminal.
  • the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet.
  • the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
  • RF Radio Frequency
  • a data update method is provided.
  • the data update method is widely used in whole-house intelligent digital control application scenarios such as smart home, smart home, smart home device ecology, and smart house ecology.
  • the above data update method can be applied to a hardware environment composed of a terminal device 102 and a server 104 as shown in Figure 2.
  • the server 104 is connected to the terminal device 102 through a network, and can be configured to provide services (such as application services, etc.) for the terminal or a client installed on the terminal.
  • a database can be set on the server or independently of the server to provide data storage services for the server 104, and cloud computing and/or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
  • the above network may include but is not limited to at least one of the following: wired network, wireless network.
  • the above wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the above wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth.
  • WIFI Wireless Fidelity
  • the terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing equipment, a smart dishwasher, a smart projection equipment, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air equipment, a smart kitchen and bathroom equipment, a smart bathroom equipment, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification equipment, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
  • FIG3 is a flow chart of the data updating method according to the embodiment of the present disclosure, and the flow chart includes the following steps:
  • Step S202 obtaining an update flag corresponding to the log content of the first database, wherein the update flag is used to indicate whether the log content of the first database has been updated;
  • the above update flag may indicate whether the log content of the entire first database is updated, or may indicate whether the log content of specified data in the first database is updated, and the present disclosure does not impose any limitation on this.
  • Step S204 when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, acquiring the second data from the first database, wherein the first data and the second data correspond to the same data identifier;
  • the above data identifier can be understood as a unique identifier for identifying a data value.
  • the data identifier can be understood as a key
  • the data corresponding to the data identifier can be understood as a value.
  • the first data corresponding to key A can be expressed as ⁇ A, A1 ⁇ .
  • the second data corresponding to key A can be expressed as ⁇ A, A2 ⁇ .
  • Step S206 determine the first data stored in the cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have synchronized the first data in advance.
  • an update identifier corresponding to the log content of the first database is obtained, and the update identifier is used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, the second data is obtained from the first database, wherein the first data and the second data correspond to the same data identifier; the first data stored in the cache is determined, and the first data stored in the cache is updated to the second data, wherein the cache and the first database have pre-synchronized the first data, which solves the technical problem of how to update the cache data in the related art to ensure that the data in the database and the cache data are consistent, and further when the cache data is updated, the data in the database and the cache data can be guaranteed to be consistent.
  • the following scheme may further be implemented: when an update confirmation ACK (Acknowledge character) identifier generated when the cache updates the first data to the second data is obtained, a first query instruction is determined according to the ACK identifier; based on the first query instruction, third data is queried from a second database, the second database is a backup database of the first database, and the third data represents backup data of the second data; when it is determined that the second data and the third data are consistent, a notification message indicating that the update is successful is sent to the terminal device.
  • an update confirmation ACK Acknowledge character
  • whether the update is successful can be determined based on whether the third data in the second database is consistent with the second data, thereby improving the accuracy of the data update result.
  • the cache is re-updated based on a retry mechanism, and a retry message indicating the re-update is sent to the terminal device, wherein the reasons for the update failure may include network disconnection, program error, program failure due to insufficient storage space, etc., but the present disclosure is not limited to this.
  • the first data stored in the cache is directly updated to the third data.
  • the second data in the cache is deleted, and the first data stored in the cache is updated to the third data.
  • the following steps may be referred to: determining the backup time for backing up the second data of the first database to the second database; generating a delay queue for delaying the cache deletion operation according to the backup time, wherein the delay queue corresponds to a delayed execution time, the start time of the delayed execution time is the change time when the first data in the first database is changed to the second data, and the end time of the delayed execution time is later than the end time of the backup time; updating the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue.
  • a technical solution is proposed for the step of updating the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue, specifically including: after the delayed execution time, deleting the first data in the cache based on the cache deletion operation; reading third data from the second database, and writing the third data into the cache.
  • a technical solution for determining the backup time of backing up the second data in the first database to the second database is further proposed, and the specific steps include: determining the historical backup time when backing up the second data in the first database to the second database, and determining the backup time based on the historical backup time, including one of the following: setting the historical backup time with the longest usage time as the backup time; setting the historical backup time with the highest usage frequency as the backup time; setting the historical backup time with the latest usage time as the backup time.
  • determining the backup time based on the historical backup time may further include determining the backup time based on an average of a plurality of the historical backup times.
  • determining the backup time required for backing up the second data in the first database to the second database are also proposed, specifically including: determining the backup time for backing up the second data in the first database to the second database according to the type of the first database, the type of the second database, and the network status when the second data in the first database is backed up to the second database, so as to determine the backup time for the second data in the first database to the second database according to the backup time.
  • a scheme for sending a notification message of successful update to a terminal device is also proposed, and the specific schemes include: Scheme 1, when it is determined that the first data cannot be found in the first database, the second database and the cache, sending a notification message indicating a successful update to the terminal device; Scheme 2, when it is determined that the second data is found in both the first database and the cache, sending a notification message indicating a successful update to the terminal device; or, when it is determined that the third data is found in both the second database and the cache, sending a notification message indicating a successful update to the terminal device.
  • FIG4 is a flow chart of the data updating method according to the embodiment of the present disclosure.
  • a technical solution is proposed. The specific steps are as follows:
  • Step S301 Execute the operation of writing data through thread A;
  • Step S302 executing data update operation through the business system
  • Step S303 Database update is successful
  • Step S304 subscribing to the log of the database through the message queue
  • thread A after thread A successfully updates the database, it uses a message queue to monitor the database Binlog log and writes the log message into the message queue.
  • Step S305 when it is determined that the database has been updated according to the subscription message of the message queue, the cache is updated;
  • Step S306 After the cache is updated successfully, an ACK confirmation message is sent to the message queue;
  • Step S307 when the cache update fails, re-update the cache based on the retry mechanism
  • the cache module monitors the log messages in the message queue. If an updated log message is detected in the message queue, the consumption operation is immediately performed to update the cache. When it is determined that the cache module has successfully consumed the update log of the message queue, the cache is updated successfully, and an ACK mark is returned to the message queue to confirm the successful consumption. If the cache module fails to successfully consume the update log of the message queue due to network or other reasons, the cache is not updated successfully and the ACK mark cannot be fed back. If the message queue does not receive the ACK mark indicating successful cache consumption, the cache module is controlled to perform the consumption operation again based on the retry mechanism until the ACK mark returned by the cache module is received. Confirm that thread A has completed updating the cache.
  • Step S309 Execute the data reading operation through thread B;
  • Step S310 Thread B reads data from the cache
  • Step S311 when the cache is empty, read data from the database
  • Step S312 updating the cache according to the data read from the database
  • Step S313 The cache feeds back to the business system whether the update is successful.
  • thread A updates the database
  • it subscribes to the binlog log of the database pushes the message related to the binlog log of the database update to the message queue, implements the Binlog log monitored by the message queue, and synchronously updates the cache, so that decoupling work can be achieved without intruding into the business code of the system.
  • the cache layer can also synchronize the updated data of the database in time to ensure the consistency of the cache and database data.
  • Figure 5 is a framework diagram of the data update method according to the embodiment of the present disclosure.
  • the business system is used to write data to the database
  • the log subscription middleware (Canal) subscribes to the database to update the binlog log
  • the cache module is set to consume the messages in the message queue to update the cache; the retry mechanism of the Message Queue ensures that the cache consumption message is ultimately successful.
  • the business system usually reads more and writes less, and a one-master-multiple-slave database mode can be adopted, that is, the master database can be set to read and write, and the slave database can only read.
  • This read-write separation method is to disperse the read and write operations of the database to different nodes, which can slightly improve the write performance and greatly improve the read performance.
  • this embodiment adopts a high-concurrency thread to initiate the read and write request of the business system, write the master database, read the slave database, thread A performs the database write operation, writes the master database; threads B and C perform the database read operation, read the slave database; wherein, after thread A successfully executes the write to the master database, another asynchronous thread is created to update the cache.
  • updating the cache it is necessary to subscribe to the update log of the master database to determine the timing of updating the cache. Based on the purpose of delaying the cache deletion operation of the delay queue, it is necessary to set the delay time of the delay queue message to be greater than the delay time of the master-slave replication.
  • the cache is deleted based on the delay time of the delay queue message, so that threads B and C read the slave database that has updated the data, and then write the data to the cache, and finally maintain the consistency of the database and the cache.
  • Figure 6 is a schematic diagram of a cache-free data update method according to an embodiment of the present disclosure. As shown in Figure 6, a request can also be directly initiated to the business system to query the database to implement a cache-free data update method. However, this method is prone to database crashes or unresponsiveness in high concurrency scenarios.
  • FIG. 7 is a flow chart of a cached data update method according to an embodiment of the present disclosure (I), and the specific steps are as follows:
  • Step S601 initiating a data read request
  • Step S602 determine whether there is data in the cache; if yes, execute step S606, if no, execute step S603;
  • Step S603 Load the data to be read from the database
  • Step S604 determine whether the data read from the database is empty; if yes, execute step S606, if no, execute step S605;
  • Step S605 writing the data read from the database into the cache
  • Step S606 Return the data read from the cache.
  • Figure 8 is a flow chart (II) of a data update method with a cache according to an embodiment of the present disclosure.
  • thread A updates the database
  • thread B reads the cache.
  • Thread A updates the cache to the new value.
  • Thread B writes the old value it reads into the cache to overwrite the new value written by thread A last time.
  • the final result is that the cache contains the old value of thread B, while the database is the new value updated by thread A. At this time, the data is inconsistent with the cache.
  • the cache if the cache is deleted first, the database has not been successfully updated. At this time, there is no new data in the cache. Data needs to be read from the database and written into the cache. At this time, the data in the cache is old data. In this embodiment, data consistency can be achieved by delayed double deletion. In order to avoid the problem that other threads cannot read data from the cache when updating data, after updating the database, you can sleep for a period of time and then delete the cache again. However, this method cannot accurately estimate the sleep time value, and there may be problems with data inconsistency.
  • the database is updated first in combination with FIG. 9 , which is a flow chart of a data update method with a cache according to an embodiment of the present disclosure (III).
  • FIG. 9 is a flow chart of a data update method with a cache according to an embodiment of the present disclosure (III). The case of deleting the cache is described. As shown in FIG. 9 , after thread A successfully updates the database, when updating the cache, if the cache fails to be deleted or there is no time to delete the cache, the update will fail. If thread B reads the cache, the value in the cache is the old value at this time, and a cache inconsistency result occurs at this time.
  • the database contains the new value and the cache contains the old value. Subsequent read requests will obtain the old data. Only after the cache expires can the correct value be stored in the database.
  • a message can be sent to the message queue. After the client consumes the message queue, the cache is deleted. At this time, the retry mechanism of the queue is used to achieve the final consistency effect.
  • the message queue is introduced in this way, the problem of how to ensure the loss, delay, and timing of the message will also be introduced, which may cause data inconsistency.
  • the embodiment of Figure 4 can obtain the tracking operation of the database in real time by subscribing to the Binlog log updated by the database operation.
  • the message middleware system based on publish-subscribe is decoupled and some functions are implemented without intruding the business system.
  • Write operations are performed through thread A, and the log middleware (Canal) is used to write messages to MQ (Kafka, racketmq) in real time; subscribe to the message queue message through the cache module to update the cache. If it fails, the retry mechanism can be used to repeat the update until the message is successfully updated.
  • the use of the retry mechanism can increase the probability of cache updates, and the cache will not be updated again due to a single failure.
  • the message timing of the message queue there will be no disorder in updating the cache, and the multi-threaded update and database timing problems can be solved.
  • the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method.
  • the technical solution of the present disclosure, or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present disclosure.
  • a storage medium such as ROM/RAM, a disk, or an optical disk
  • FIG10 is a structural block diagram of a data updating device according to an embodiment of the present disclosure; as shown in FIG10 , the device comprises:
  • a first update module 92 configured to obtain an update identifier corresponding to the log content of the first database, wherein the update identifier is used to indicate whether the log content of the first database has been updated;
  • the above update flag may indicate whether the log content of the entire first database is updated, or may indicate whether the log content of specified data in the first database is updated, and the present disclosure does not impose any limitation on this.
  • An acquisition module 94 is configured to acquire the second data from the first database when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, wherein the first data and the second data correspond to the same data identifier;
  • the above data identifier can be understood as a unique identifier for identifying a data value.
  • the data identifier can be understood as a key
  • the data corresponding to the data identifier can be understood as a value.
  • the first data corresponding to key A can be expressed as ⁇ A, A1 ⁇ .
  • the second data corresponding to key A can be expressed as ⁇ A, A2 ⁇ .
  • the second updating module 96 is configured to determine the first data stored in the cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
  • an update identifier corresponding to the log content of the first database is obtained, and the update identifier is used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, the second data is obtained from the first database, wherein the first data and the second data correspond to the same data identifier; the first data stored in the cache is determined, and the first data stored in the cache is updated to the second data, wherein the cache and the first database have pre-synchronized the first data, which solves the technical problem in the related art of how to update the cache data to ensure that the data in the database and the cache data are consistent, and further when the cache data is updated, it can ensure that the data in the database and the cache data are consistent.
  • the above-mentioned data update device also includes: a determination module, which is configured to determine a first query instruction according to an update confirmation ACK identifier generated when the cache updates the first data to the second data; based on the first query instruction, query third data from a second database, the second database is a backup database of the first database, and the third data represents the backup data of the second data; when it is determined that the second data and the third data are consistent, send a notification message to the terminal device to indicate that the update is successful.
  • a determination module which is configured to determine a first query instruction according to an update confirmation ACK identifier generated when the cache updates the first data to the second data
  • query third data from a second database
  • the second database is a backup database of the first database
  • the third data represents the backup data of the second data
  • the cache is re-updated based on a retry mechanism, and a retry message indicating the re-update is sent to the terminal device, wherein the reasons for the update failure may include network disconnection, program error, program failure due to insufficient storage space, etc., but the present disclosure is not limited to this.
  • the first data stored in the cache is directly updated to the third data.
  • the second data in the cache is deleted, and the first data stored in the cache is updated to the third data.
  • the second update module 96 is further configured to determine a backup time for backing up the second data of the first database to the second database; generate a delay queue for delaying cache deletion operations according to the backup time, wherein the delay queue corresponds to a delayed execution time, the start time of the delayed execution time is the change time when the first data in the first database is changed to the second data, and the end time of the delayed execution time is later than the end time of the backup time; and update the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue.
  • the second update module 96 is further configured to delete the first data in the cache based on the cache deletion operation after the delayed execution time; read the third data from the second database, and write the third data into the cache.
  • the second update module 96 is further configured to determine the historical backup time when backing up the second data in the first database to the second database, and to determine the backup time based on the historical backup time, including one of the following: setting the historical backup time with the longest usage time as the backup time; setting the historical backup time with the highest usage frequency as the backup time; setting the historical backup time with the latest usage time as the backup time.
  • determining the backup time based on the historical backup time may further include determining the backup time based on an average of a plurality of the historical backup times.
  • the second update module 96 is further configured to determine a backup time for backing up the second data in the first database to the second database based on the type of the first database, the type of the second database, and the network status when the second data in the first database is backed up to the second database, so as to determine the backup time for backing up the second data in the first database to the second database based on the backup time.
  • the above-mentioned data update device also includes: a sending module, which is configured to send a notification message indicating a successful update to a terminal device when it is determined that the first data cannot be found in the first database, the second database and the cache; or, when it is determined that the second data is found in both the first database and the cache, send a notification message indicating a successful update to the terminal device; or, when it is determined that the third data is found in both the second database and the cache, send a notification message indicating a successful update to the terminal device.
  • a sending module which is configured to send a notification message indicating a successful update to a terminal device when it is determined that the first data cannot be found in the first database, the second database and the cache; or, when it is determined that the second data is found in both the first database and the cache, send a notification message indicating a successful update to the terminal device; or, when it is determined that the third data is found in both the second database and the cache, send a notification message indicating a successful update to
  • An embodiment of the present disclosure further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.
  • the storage medium may be configured to store program codes for executing the following steps:
  • An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
  • the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
  • the processor may be configured to perform the following steps through a computer program:
  • the above-mentioned storage medium may include but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
  • modules or steps of the present disclosure can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation.
  • the present disclosure is not limited to any specific combination of hardware and software.

Landscapes

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

Abstract

The present disclosure relates to the technical field of smart home and provides a data update method and apparatus, a storage medium, and an electronic apparatus. The data update method comprises: acquiring an update identifier corresponding to log content of a first database, the update identifier being used for representing whether the log content of the first database is updated or not; when it is determined that the update identifier indicates that first data in the first database changes into second data, acquiring the second data from the first database, wherein the first data and the second data correspond to the same data identifier; and determining the first data stored in a cache, and updating the first data stored in the cache into the second data.

Description

数据更新方法、装置、存储介质及电子装置Data updating method, device, storage medium and electronic device
本公开要求于2022年09月29日提交中国专利局、申请号为202211203452.0、发明名称“数据更新方法、装置、存储介质及电子装置”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure claims the priority of the Chinese patent application filed with the China Patent Office on September 29, 2022, with application number 202211203452.0 and invention name “Data update method, device, storage medium and electronic device”, the entire contents of which are incorporated by reference in this disclosure.
技术领域Technical Field
本公开涉及智慧家庭技术领域,具体而言,涉及一种数据更新方法、装置、存储介质及电子装置。The present disclosure relates to the field of smart home technology, and in particular to a data updating method, device, storage medium and electronic device.
背景技术Background technique
目前,数据访问的过程一般是用户并发访问业务系统的数据,由系统返回响应信息。但是在现代互联网高并发的业务场景下,对于不定时的高并发的访问时产生的大量数据IO操作,这些数据访问请求的操作如果直接到数据库,很有可能直接造成数据库的宕机和不可用。由此,造成较为严重的业务故障或系统异常。At present, the process of data access is generally that users concurrently access the data of the business system, and the system returns response information. However, in the high-concurrency business scenarios of the modern Internet, for the large amount of data IO operations generated by irregular high-concurrency access, if these data access requests are directly sent to the database, it is very likely to directly cause the database to crash and become unavailable, thus causing more serious business failures or system abnormalities.
基于以上的问题,我们需要在业务系统和数据库系统之间引入一层缓存,让高并发的用户请求IO操作,先查询缓存。然而随着缓存技术的引入,又会导致数据的不一致性问题,即数据库更新后和缓存数据的一致性问题。Based on the above problems, we need to introduce a layer of cache between the business system and the database system, so that high-concurrency users can query the cache first when requesting IO operations. However, with the introduction of cache technology, data inconsistency problems will arise, that is, the consistency problem between the database and the cached data after the update.
因此,相关技术中,存在如何对缓存数据进行更新,以保证数据库中数据和缓存数据一致的技术问题。Therefore, in the related art, there is a technical problem of how to update the cached data to ensure that the data in the database is consistent with the cached data.
针对相关技术中,如何对缓存数据进行更新,以保证数据库中数据和缓存数据一致的技术问题,尚未提出有效的解决方案。In the related art, an effective solution has not yet been proposed for the technical problem of how to update cached data to ensure that the data in the database is consistent with the cached data.
发明内容Summary of the invention
本公开实施例提供了一种数据更新方法、装置、存储介质及电子装置,以至少解决相关技术中,如何对缓存数据进行更新,以保证数据库中数据和缓存数据一致的技术问题。The embodiments of the present disclosure provide a data updating method, device, storage medium and electronic device to at least solve the technical problem in the related art of how to update cache data to ensure that the data in the database is consistent with the cache data.
根据本公开实施例的一个实施例,提供了一种数据更新方法,包括:获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。According to an embodiment of the present disclosure, a data updating method is provided, including: obtaining an update identifier corresponding to log content of a first database, the update identifier being used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that first data in the first database is changed to second data, obtaining the second data from the first database, wherein the first data and the second data correspond to the same data identifier; determining the first data stored in a cache, and updating the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
根据本公开实施例的另一个实施例,还提供了一种数据更新装置,包括:第一更新模块,设置为获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否更新;获取模块,设置为在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;第二更新模块,设置为确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。According to another embodiment of the embodiments of the present disclosure, a data updating device is also provided, including: a first updating module, configured to obtain an update identifier corresponding to the log content of a first database, wherein the update identifier is used to indicate whether the log content of the first database is updated; an obtaining module, configured to obtain the second data from the first database when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, wherein the first data and the second data correspond to the same data identifier; a second updating module, configured to determine the first data stored in a cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
根据本公开实施例的又一方面,还提供了一种计算机可读的存储介质,该计算机可读的存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述数据更新方法。According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above data updating method when running.
根据本公开实施例的又一方面,还提供了一种电子装置,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,上述处理器通过计算机程序执行上述的数据更新方法。According to another aspect of the embodiments of the present disclosure, there is also provided an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the data updating method through the computer program.
在本公开实施例中,获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;在确定所述更新标识指示所述第一数据库中的第一数据变更为,其中,和所述第一数据对应于同一数据标识的第二数据的情况下,从所述第一数据库中获取所述第二数据;确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。In an embodiment of the present disclosure, an update identifier corresponding to the log content of the first database is obtained, and the update identifier is used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that the first data in the first database is changed to, wherein the second data corresponds to the same data identifier as the first data, the second data is obtained from the first database; the first data stored in the cache is determined, and the first data stored in the cache is updated to the second data, wherein the cache and the first database have pre-synchronized the first data.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
图1是本申请实施例的一种意图指令的确定方法的计算机终端的硬件结构框图;FIG1 is a hardware structure block diagram of a computer terminal of a method for determining an intention instruction according to an embodiment of the present application;
图2是本公开实施例的一种数据更新方法的硬件环境示意图;FIG2 is a schematic diagram of a hardware environment of a data updating method according to an embodiment of the present disclosure;
图3是根据本公开实施例的数据更新方法的流程图;FIG3 is a flow chart of a data updating method according to an embodiment of the present disclosure;
图4是根据本公开实施例的数据更新方法的流程示意图;FIG4 is a flow chart of a data updating method according to an embodiment of the present disclosure;
图5是根据本公开实施例的数据更新方法的框架示意图;FIG5 is a schematic diagram of a data updating method according to an embodiment of the present disclosure;
图6是根据本公开实施例的一种无缓存的数据更新方法的示意图;FIG6 is a schematic diagram of a method for updating data without caching according to an embodiment of the present disclosure;
图7是根据本公开实施例的一种有缓存的数据更新方法的流程示意图(一);FIG7 is a flow chart of a method for updating data with cache according to an embodiment of the present disclosure (I);
图8是根据本公开实施例的一种有缓存的数据更新方法的流程示意图(二);FIG8 is a flow chart of a method for updating data with cache according to an embodiment of the present disclosure (II);
图9是根据本公开实施例的一种有缓存的数据更新方法的流程示意图(三);FIG9 is a flow chart of a method for updating data with cache according to an embodiment of the present disclosure (III);
图10是根据本公开实施例的一种数据更新装置的结构框图。FIG. 10 is a structural block diagram of a data updating device according to an embodiment of the present disclosure.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本公开方案,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分的实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本公开保护的范围。In order to enable those skilled in the art to better understand the scheme of the present disclosure, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present disclosure.
需要说明的是,本公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本公开的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
本申请实施例所提供的方法实施例可以在计算机终端或者类似的运算装置中执行。以运行在计算机终端上为例,图1是本申请实施例的一种意图指令的确定方法的计算机终端的硬件结构框图。如图1所示,计算机终端可以包括一个或多个(图1中仅示出一个)处理器202(处理器202可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和用于存储数据的存储器204,在一个示例性实施例中,上述计算机终端还可以包括用于通信功能的传输设备106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述计算机终端的结构造成限定。例如,计算机终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示等同功能或比图1所示功能更多的不同的配置。The method embodiment provided in the embodiment of the present application can be executed in a computer terminal or a similar computing device. Taking running on a computer terminal as an example, FIG. 1 is a hardware structure block diagram of a computer terminal of a method for determining an intention instruction in an embodiment of the present application. As shown in FIG. 1 , the computer terminal may include one or more (only one is shown in FIG. 1 ) processors 202 (the processor 202 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 204 for storing data. In an exemplary embodiment, the above-mentioned computer terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those of ordinary skill in the art that the structure shown in FIG. 1 is only for illustration, and it does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal may also include more or fewer components than those shown in FIG. 1 , or have different configurations with equivalent functions as shown in FIG. 1 or more functions than those shown in FIG. 1 .
存储器204可用于存储计算机程序,例如,应用软件的软件程序以及模块,如本申请实施例中的意图指令的确定方法对应的计算机程序,处理器202通过运行存储在存储器204内的计算机程序,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器204可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器204可进一步包括相对于处理器202远程设置的存储器,这些远程存储器可以通过网络连接至计算机终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 204 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the determination method of the intention instruction in the embodiment of the present application. The processor 202 executes various functional applications and data processing by running the computer program stored in the memory 204, that is, to implement the above method. The memory 204 may include a high-speed random access memory, and may also include a 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 204 may further include a memory remotely arranged relative to the processor 202, and these remote memories can be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
传输设备106用于经由一个网络接收或者发送数据。上述的网络具体实例可 包括计算机终端的通信供应商提供的无线网络。在一个实例中,传输设备106包括一个网络适配器(Network Interface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输设备106可以为射频(Radio Frequency,简称为RF)模块,其用于通过无线方式与互联网进行通讯。The transmission device 106 is used to receive or send data via a network. The specific example of the above network 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, referred to as 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 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
根据本公开实施例的一个方面,提供了一种数据更新方法。该数据更新方法广泛应用于智慧家庭(Smart Home)、智能家居、智能家用设备生态、智慧住宅(Intelligence House)生态等全屋智能数字化控制应用场景。可选地,在本实施例中,上述数据更新方法可以应用于如图2所示的由终端设备102和服务器104所构成的硬件环境中。如图2所示,服务器104通过网络与终端设备102进行连接,可设置为为终端或终端上安装的客户端提供服务(如应用服务等),可在服务器上或独立于服务器设置数据库,用于为服务器104提供数据存储服务,可在服务器上或独立于服务器配置云计算和/或边缘计算服务,用于为服务器104提供数据运算服务。According to one aspect of the embodiments of the present disclosure, a data update method is provided. The data update method is widely used in whole-house intelligent digital control application scenarios such as smart home, smart home, smart home device ecology, and smart house ecology. Optionally, in this embodiment, the above data update method can be applied to a hardware environment composed of a terminal device 102 and a server 104 as shown in Figure 2. As shown in Figure 2, the server 104 is connected to the terminal device 102 through a network, and can be configured to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104, and cloud computing and/or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
上述网络可以包括但不限于以下至少之一:有线网络,无线网络。上述有线网络可以包括但不限于以下至少之一:广域网,城域网,局域网,上述无线网络可以包括但不限于以下至少之一:WIFI(Wireless Fidelity,无线保真),蓝牙。终端设备102可以并不限定于为PC、手机、平板电脑、智能空调、智能烟机、智能冰箱、智能烤箱、智能炉灶、智能洗衣机、智能热水器、智能洗涤设备、智能洗碗机、智能投影设备、智能电视、智能晾衣架、智能窗帘、智能影音、智能插座、智能音响、智能音箱、智能新风设备、智能厨卫设备、智能卫浴设备、智能扫地机器人、智能擦窗机器人、智能拖地机器人、智能空气净化设备、智能蒸箱、智能微波炉、智能厨宝、智能净化器、智能饮水机、智能门锁等。The above network may include but is not limited to at least one of the following: wired network, wireless network. The above wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the above wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing equipment, a smart dishwasher, a smart projection equipment, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air equipment, a smart kitchen and bathroom equipment, a smart bathroom equipment, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification equipment, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
在本实施例中提供了一种数据更新方法,应用于上述计算机终端,图3是根据本公开实施例的数据更新方法的流程图,该流程包括如下步骤:In this embodiment, a data updating method is provided, which is applied to the above-mentioned computer terminal. FIG3 is a flow chart of the data updating method according to the embodiment of the present disclosure, and the flow chart includes the following steps:
步骤S202,获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;Step S202, obtaining an update flag corresponding to the log content of the first database, wherein the update flag is used to indicate whether the log content of the first database has been updated;
需要说明的是,上述更新标识可以表示整个第一数据库的日志内容是否更新,也可以表示第一数据库内的指定数据的日志内容是否更新,本公开对此不作限制。It should be noted that the above update flag may indicate whether the log content of the entire first database is updated, or may indicate whether the log content of specified data in the first database is updated, and the present disclosure does not impose any limitation on this.
步骤S204,在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;Step S204, when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, acquiring the second data from the first database, wherein the first data and the second data correspond to the same data identifier;
其中,上述数据标识可以理解为识别数据值的唯一标识,例如键值对形式中,可以将数据标识理解为键,将数据标识对应的数据理解为值。具体的,例如以数据标识以键A为例,以第一数据为数据A1为例,以第二数据为A2为例,则第一数据对应于键A可以表示为{A,A1},当第一数据更新为第二数据之后,第二数据对应于键A可以表示为{A,A2}。The above data identifier can be understood as a unique identifier for identifying a data value. For example, in the form of a key-value pair, the data identifier can be understood as a key, and the data corresponding to the data identifier can be understood as a value. Specifically, for example, taking the data identifier as key A, the first data as data A1, and the second data as A2, the first data corresponding to key A can be expressed as {A, A1}. When the first data is updated to the second data, the second data corresponding to key A can be expressed as {A, A2}.
步骤S206,确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。Step S206: determine the first data stored in the cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have synchronized the first data in advance.
通过上述步骤,获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据,解决了相关技术中,如何对缓存数据进行更新,以保证数据库中数据和缓存数据一致的技术问题,进而在对缓存数据进行更新时,能够保证数据库中数据和缓存数据一致。Through the above steps, an update identifier corresponding to the log content of the first database is obtained, and the update identifier is used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, the second data is obtained from the first database, wherein the first data and the second data correspond to the same data identifier; the first data stored in the cache is determined, and the first data stored in the cache is updated to the second data, wherein the cache and the first database have pre-synchronized the first data, which solves the technical problem of how to update the cache data in the related art to ensure that the data in the database and the cache data are consistent, and further when the cache data is updated, the data in the database and the cache data can be guaranteed to be consistent.
在一个示例性实施例中,在将所述缓存中保存的第一数据更新为所述第二数据之后,进一步的,还可以实现下述方案:在获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK(Acknowledge character)标识的情况下,根据所述ACK标识确定第一查询指令;基于所述第一查询指令从第二数据库查询到第三数据,所述第二数据库为所述第一数据库的备份数据库,所述第三数据表示所述第二数据的备份数据;在确定所述第二数据和所述第三数据一致的情况下,向终端设备发送用于表示更新成功的通知消息。In an exemplary embodiment, after the first data stored in the cache is updated to the second data, the following scheme may further be implemented: when an update confirmation ACK (Acknowledge character) identifier generated when the cache updates the first data to the second data is obtained, a first query instruction is determined according to the ACK identifier; based on the first query instruction, third data is queried from a second database, the second database is a backup database of the first database, and the third data represents backup data of the second data; when it is determined that the second data and the third data are consistent, a notification message indicating that the update is successful is sent to the terminal device.
通过上述实施例,可以根据第二数据库内的第三数据与第二数据是否一致来确定是否更新成功,提高了数据更新结果的准确性。Through the above embodiment, whether the update is successful can be determined based on whether the third data in the second database is consistent with the second data, thereby improving the accuracy of the data update result.
在一个实施例中,在未获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,可以确定上述缓存没有成功更新,则基于重试机制重新更新缓存,并向终端设备发送用于表示重新更新的重试消息,其中,更新失败的原因可以包括断网、程序错误、由于无足够存储空间导致程序运行失败等,本公开不限于此。In one embodiment, if the update confirmation ACK identifier generated when the cache updates the first data to the second data is not obtained, it can be determined that the above-mentioned cache has not been successfully updated, then the cache is re-updated based on a retry mechanism, and a retry message indicating the re-update is sent to the terminal device, wherein the reasons for the update failure may include network disconnection, program error, program failure due to insufficient storage space, etc., but the present disclosure is not limited to this.
或者,在未获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,直接将所述缓存中保存的第一数据更新为所述第三数据。Alternatively, when an update confirmation ACK identifier generated when the cache updates the first data to the second data is not obtained, the first data stored in the cache is directly updated to the third data.
在其他实施例中,在确定所述第二数据和所述第三数据不一致的情况下,删除缓存内的第二数据,将所述缓存中保存的第一数据更新为所述第三数据。In other embodiments, when it is determined that the second data and the third data are inconsistent, the second data in the cache is deleted, and the first data stored in the cache is updated to the third data.
在一个示例性实施例中,为了更好的理解上述步骤S206中如何实现将所述缓存中保存的第一数据更新为所述第二数据的过程,可以参照下述步骤:确定将所述第一数据库的第二数据备份至所述第二数据库的备份时间;根据所述备份时间生成用于延迟缓存删除操作的延时队列,其中,所述延时队列对应有延时执行时间,所述延时执行时间的开始时刻为所述第一数据库中的第一数据变更为第二数据的变更时刻,所述延时执行时间的结束时刻晚于所述备份时间的结束时刻;根据所述延时队列对应的延时执行时间将所述缓存中保存的第一数据更新为所述第二数据。In an exemplary embodiment, in order to better understand how to implement the process of updating the first data stored in the cache to the second data in the above-mentioned step S206, the following steps may be referred to: determining the backup time for backing up the second data of the first database to the second database; generating a delay queue for delaying the cache deletion operation according to the backup time, wherein the delay queue corresponds to a delayed execution time, the start time of the delayed execution time is the change time when the first data in the first database is changed to the second data, and the end time of the delayed execution time is later than the end time of the backup time; updating the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue.
在一个示例性实施例中,针对根据所述延时队列对应的延时执行时间将所述缓存中保存的第一数据更新为所述第二数据的步骤,提出了一种技术方案,具体包括:在经过所述延时执行时间之后,基于所述缓存删除操作将所述缓存中的第一数据删除;从所述第二数据库内读取第三数据,并将所述第三数据写入所述缓存。In an exemplary embodiment, a technical solution is proposed for the step of updating the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue, specifically including: after the delayed execution time, deleting the first data in the cache based on the cache deletion operation; reading third data from the second database, and writing the third data into the cache.
在一个示例性实施例中,进而提出了一种确定将所述第一数据库的第二数据 备份至所述第二数据库的备份时间的技术方案,具体步骤包括:确定将所述第一数据库中的第二数据备份至第二数据库时的历史备份时间,基于所述历史备份时间确定所述备份时间,包括以下之一:将使用时间最长的历史备份时间设置为所述备份时间;将使用频次最高的历史备份时间设置为所述备份时间;将使用时间最新的历史备份时间设置为所述备份时间。In an exemplary embodiment, a technical solution for determining the backup time of backing up the second data in the first database to the second database is further proposed, and the specific steps include: determining the historical backup time when backing up the second data in the first database to the second database, and determining the backup time based on the historical backup time, including one of the following: setting the historical backup time with the longest usage time as the backup time; setting the historical backup time with the highest usage frequency as the backup time; setting the historical backup time with the latest usage time as the backup time.
其中,基于所述历史备份时间确定所述备份时间还可以包括基于多个所述历史备份时间的均值确定所述备份时间。Wherein, determining the backup time based on the historical backup time may further include determining the backup time based on an average of a plurality of the historical backup times.
在一个示例性实施例中,可选的,还提出了其他用于确定将所述第一数据库中的第二数据备份至第二数据库时所需的备份时间的技术方案,具体包括:根据所述第一数据库的类型、所述第二数据库的类型和所述第一数据库中的第二数据备份至第二数据库时的网络状态确定将所述第一数据库中的第二数据备份至第二数据库时的备份时间,以根据所述备份时间确定将所述第一数据库中的第二数据备份至第二数据库。In an exemplary embodiment, optionally, other technical solutions for determining the backup time required for backing up the second data in the first database to the second database are also proposed, specifically including: determining the backup time for backing up the second data in the first database to the second database according to the type of the first database, the type of the second database, and the network status when the second data in the first database is backed up to the second database, so as to determine the backup time for the second data in the first database to the second database according to the backup time.
在一个示例性实施例中,可选的,还提出了一种向终端设备发送更新成功的通知消息的方案,具体方案包括:方案1、在确定所述第一数据库、所述第二数据库和所述缓存中均查询不到所述第一数据的情况下,向终端设备发送用于表示更新成功的通知消息;方案2、在确定所述第一数据库和所述缓存中均查询到所述第二数据的情况下,向终端设备发送用于表示更新成功的通知消息;或者,在确定所述第二数据库和所述缓存中均查询到第三数据的情况下,向终端设备发送用于表示更新成功的通知消息。In an exemplary embodiment, optionally, a scheme for sending a notification message of successful update to a terminal device is also proposed, and the specific schemes include: Scheme 1, when it is determined that the first data cannot be found in the first database, the second database and the cache, sending a notification message indicating a successful update to the terminal device; Scheme 2, when it is determined that the second data is found in both the first database and the cache, sending a notification message indicating a successful update to the terminal device; or, when it is determined that the third data is found in both the second database and the cache, sending a notification message indicating a successful update to the terminal device.
为了更好的理解上述数据更新方法的过程,以下再结合可选实施例对上述数据更新的实现方法流程进行说明,但不用于限定本公开实施例的技术方案。In order to better understand the process of the above data updating method, the implementation method flow of the above data updating is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of the present disclosure.
在本实施例中提供了一种数据更新方法,图4是根据本公开实施例的数据更新方法的流程示意图,结合图4提出一种技术方案,具体步骤如下:In this embodiment, a data updating method is provided. FIG4 is a flow chart of the data updating method according to the embodiment of the present disclosure. In conjunction with FIG4 , a technical solution is proposed. The specific steps are as follows:
步骤S301:通过线程A执行写入数据的操作;Step S301: Execute the operation of writing data through thread A;
步骤S302:通过业务系统执行对数据更新的操作;Step S302: executing data update operation through the business system;
步骤S303:数据库更新成功;Step S303: Database update is successful;
步骤S304:通过消息队列订阅数据库的日志;Step S304: subscribing to the log of the database through the message queue;
在一个实施例中,在线程A更新数据库成功后,使用消息队列监听数据库Binlog日志,把日志消息写入消息队列。In one embodiment, after thread A successfully updates the database, it uses a message queue to monitor the database Binlog log and writes the log message into the message queue.
步骤S305:在根据消息队列的订阅消息确定数据库已经更新的情况下,对缓存进行更新;Step S305: when it is determined that the database has been updated according to the subscription message of the message queue, the cache is updated;
步骤S306:缓存更新成功后向消息队列发送ACK确认消息;Step S306: After the cache is updated successfully, an ACK confirmation message is sent to the message queue;
步骤S307:缓存更新失败时,基于重试机制重新更新缓存;Step S307: when the cache update fails, re-update the cache based on the retry mechanism;
在一个实施例中,缓存模块监听消息队列中的日志消息,如果监听到消息队列中有更新的日志消息,则立即执行消费操作,以更新缓存;在确定缓存模块成功消费了消息队列的更新日志时,缓存更新成功,继续返回给消息队列ACK标识,确认消费成功;如果缓存模块由于网络等原因,没有成功消费消息队列的更新日志,则缓存没有更新成功,无法反馈ACK标识。如果消息队列没有收到缓存消费成功的ACK标识,就基于重试机制再次控制缓存模块执行消费操作,直到收到缓存模块返回的ACK标识。确认线程A更新缓存完毕。In one embodiment, the cache module monitors the log messages in the message queue. If an updated log message is detected in the message queue, the consumption operation is immediately performed to update the cache. When it is determined that the cache module has successfully consumed the update log of the message queue, the cache is updated successfully, and an ACK mark is returned to the message queue to confirm the successful consumption. If the cache module fails to successfully consume the update log of the message queue due to network or other reasons, the cache is not updated successfully and the ACK mark cannot be fed back. If the message queue does not receive the ACK mark indicating successful cache consumption, the cache module is controlled to perform the consumption operation again based on the retry mechanism until the ACK mark returned by the cache module is received. Confirm that thread A has completed updating the cache.
步骤S309:通过线程B执行读取数据的操作;Step S309: Execute the data reading operation through thread B;
步骤S310:线程B从缓存中读取数据;Step S310: Thread B reads data from the cache;
步骤S311:在缓存为空时,从数据库内读取数据;Step S311: when the cache is empty, read data from the database;
步骤S312:根据数据库内读取到的数据更新缓存;Step S312: updating the cache according to the data read from the database;
步骤S313:由缓存向业务系统反馈是否更新成功。Step S313: The cache feeds back to the business system whether the update is successful.
通过上述实施例,线程A更新数据库后,订阅数据库的binlog日志,将数据库更新的binlog日志相关的消息推送到消息队列,实现使用消息队列监听的Binlog日志,同步更新缓存,可以在不侵入到系统的业务代码的情况下实现解耦工作,这样,业务系统在运行过程中,缓存层也能及时同步数据库的更新数据, 保证缓存和数据库数据的一致性。Through the above embodiment, after thread A updates the database, it subscribes to the binlog log of the database, pushes the message related to the binlog log of the database update to the message queue, implements the Binlog log monitored by the message queue, and synchronously updates the cache, so that decoupling work can be achieved without intruding into the business code of the system. In this way, during the operation of the business system, the cache layer can also synchronize the updated data of the database in time to ensure the consistency of the cache and database data.
在一个实施例中,图5是根据本公开实施例的数据更新方法的框架示意图,如图5所示,其中,业务系统用于写入数据到数据库,日志订阅中间件(Canal)订阅数据库更新binlog日志,将Binlog日志写入Message Quene,缓存模块设置为消费消息队列中的消息从而更新缓存;Message Queue的重试机制确保缓存消费消息最终成功。In one embodiment, Figure 5 is a framework diagram of the data update method according to the embodiment of the present disclosure. As shown in Figure 5, the business system is used to write data to the database, the log subscription middleware (Canal) subscribes to the database to update the binlog log, and writes the Binlog log to the Message Queue. The cache module is set to consume the messages in the message queue to update the cache; the retry mechanism of the Message Queue ensures that the cache consumption message is ultimately successful.
在高并发的业务系统中,通常业务系统是读多写少,可以采用数据库一主多从的方式,即设置主库可以读写,从库只读。这种读写分离的方式是将对数据库的读写操作分散到不同的节点上,能够小幅提升写性能,大幅提升读性能。基于此,本实施例采取高并发线程发起业务系统的读写请求,写主库,读从库,线程A执行数据库写操作,写主库;线程B、C执行数据库读取操作,读从库;其中,线程A执行写主数据库成功以后,另新建一个异步线程,更新缓存。在更新缓存时,需要订阅主数据库更新日志确定更新缓存的时机,基于延迟队列延迟缓存删除操作的目的,需要设置延迟队列消息的延迟时间大于主从复制的延迟时间。在主从数据库同步更新数据后,基于延迟队列消息的延迟时间删除缓存,以便线程B、C读取已经更新数据的从库,然后将数据写入缓存,最终保持数据库与缓存的一致性。In a high-concurrency business system, the business system usually reads more and writes less, and a one-master-multiple-slave database mode can be adopted, that is, the master database can be set to read and write, and the slave database can only read. This read-write separation method is to disperse the read and write operations of the database to different nodes, which can slightly improve the write performance and greatly improve the read performance. Based on this, this embodiment adopts a high-concurrency thread to initiate the read and write request of the business system, write the master database, read the slave database, thread A performs the database write operation, writes the master database; threads B and C perform the database read operation, read the slave database; wherein, after thread A successfully executes the write to the master database, another asynchronous thread is created to update the cache. When updating the cache, it is necessary to subscribe to the update log of the master database to determine the timing of updating the cache. Based on the purpose of delaying the cache deletion operation of the delay queue, it is necessary to set the delay time of the delay queue message to be greater than the delay time of the master-slave replication. After the master and slave databases synchronously update the data, the cache is deleted based on the delay time of the delay queue message, so that threads B and C read the slave database that has updated the data, and then write the data to the cache, and finally maintain the consistency of the database and the cache.
在其他实施例中,图6是根据本公开实施例的一种无缓存的数据更新方法的示意图,如图6所示,还可以直接向业务系统发起请求,查询数据库实现无缓存的数据更新方法,不过这种方法在高并发场景下容易造成数据库宕机或者无响应的问题。In other embodiments, Figure 6 is a schematic diagram of a cache-free data update method according to an embodiment of the present disclosure. As shown in Figure 6, a request can also be directly initiated to the business system to query the database to implement a cache-free data update method. However, this method is prone to database crashes or unresponsiveness in high concurrency scenarios.
可选的,在一个实施例中,为了更好的理解上述步骤步骤S309-S313的过程,结合图7对此过程进行说明,图7是根据本公开实施例的一种有缓存的数据更新方法的流程示意图(一),具体步骤如下:Optionally, in one embodiment, in order to better understand the process of the above steps S309-S313, this process is described in conjunction with FIG. 7, which is a flow chart of a cached data update method according to an embodiment of the present disclosure (I), and the specific steps are as follows:
步骤S601、发起数据读取请求;Step S601, initiating a data read request;
步骤S602、判断缓存中是否存在数据;若为是,则执行步骤S606,若为否, 则执行步骤S603;Step S602, determine whether there is data in the cache; if yes, execute step S606, if no, execute step S603;
步骤S603、从数据库内加载需要读取的数据;Step S603: Load the data to be read from the database;
步骤S604、判断从数据库内读取的数据是否为空;若为是,则执行步骤S606,若为否,则执行步骤S605;Step S604, determine whether the data read from the database is empty; if yes, execute step S606, if no, execute step S605;
步骤S605、将数据库内读取的数据写入缓存;Step S605, writing the data read from the database into the cache;
步骤S606、返回从缓存中读取到的数据。Step S606: Return the data read from the cache.
基于上述实施例,可选的,结合图8对先删除缓存,再更新数据库的情况进行说明。如图8所示,图8是根据本公开实施例的一种有缓存的数据更新方法的流程示意图(二),线程A更新数据库时,线程A先删除缓存;随后线程B读取缓存,这个时候缓存为空,如果线程B查询数据库,此时线程A还没有更新数据库成功,线程B读取到的仍然是旧值。随后,线程A将数据库更新成功。线程A将缓存更新为新值。线程B将读取到的旧值写入缓存覆盖线程A上次写入的新值。最终的结果是缓存中是线程B的旧值,而数据库是线程A更新的新值,这个时候数据就和缓存发生了不一致结果。Based on the above embodiment, optionally, in combination with Figure 8, the situation of deleting the cache first and then updating the database is described. As shown in Figure 8, Figure 8 is a flow chart (II) of a data update method with a cache according to an embodiment of the present disclosure. When thread A updates the database, thread A first deletes the cache; then thread B reads the cache. At this time, the cache is empty. If thread B queries the database, thread A has not successfully updated the database at this time, and thread B still reads the old value. Subsequently, thread A successfully updates the database. Thread A updates the cache to the new value. Thread B writes the old value it reads into the cache to overwrite the new value written by thread A last time. The final result is that the cache contains the old value of thread B, while the database is the new value updated by thread A. At this time, the data is inconsistent with the cache.
本实施例中,如果先删除缓存,数据库还没有更新成功,此时缓存不存在新数据,需要从数据库中读取数据,并将读取到的数据写入缓存,此时缓存中的数据为旧数据。本实施例中,可以通过延时双删的方式实现数据的一致性,为了避免更新数据的时候,其他线程从缓存中读取不到数据的问题,在更新完数据库后,可以sleep(静默)一段时间,然后再次删除缓存即可。但是这种方式不能准确的估算sleep时间值,还可能存在数据不一致的问题。In this embodiment, if the cache is deleted first, the database has not been successfully updated. At this time, there is no new data in the cache. Data needs to be read from the database and written into the cache. At this time, the data in the cache is old data. In this embodiment, data consistency can be achieved by delayed double deletion. In order to avoid the problem that other threads cannot read data from the cache when updating data, after updating the database, you can sleep for a period of time and then delete the cache again. However, this method cannot accurately estimate the sleep time value, and there may be problems with data inconsistency.
在其他实施例中,可选的,结合图9对先更新数据库,图9是根据本公开实施例的一种有缓存的数据更新方法的流程示意图(三)。在删除缓存的情况进行说明。如图9所示,线程A更新数据库成功后,在更新缓存时,出现删除缓存失败或者还没有来得及删除缓存等问题就会导致更新失败。如果线程B去读缓存,此时缓存中的值为旧值,这个时候就出现了缓存不一致结果。In other embodiments, optionally, the database is updated first in combination with FIG. 9 , which is a flow chart of a data update method with a cache according to an embodiment of the present disclosure (III). The case of deleting the cache is described. As shown in FIG. 9 , after thread A successfully updates the database, when updating the cache, if the cache fails to be deleted or there is no time to delete the cache, the update will fail. If thread B reads the cache, the value in the cache is the old value at this time, and a cache inconsistency result occurs at this time.
本实施例中,如果数据库更新成功了,但是缓存删除失败,那么此时数据库 中的是新值,缓存中的是旧值,之后的读请求拿到的都是旧数据,只有等缓存失效后,才能存数据库中获得正确的值。本实施例中,可以在更新数据库成功后,往消息队列中发送消息,客户端消费到消息队列后删除缓存,此时借助于队列的重试机制来实现,达到最终的一致性效果。但是这种方式引入消息队列后,也会引入如何保证消息的丢失、延迟、时序性等问题,可能带来数据不一致的问题。In this embodiment, if the database is updated successfully but the cache deletion fails, then the database contains the new value and the cache contains the old value. Subsequent read requests will obtain the old data. Only after the cache expires can the correct value be stored in the database. In this embodiment, after the database is updated successfully, a message can be sent to the message queue. After the client consumes the message queue, the cache is deleted. At this time, the retry mechanism of the queue is used to achieve the final consistency effect. However, after the message queue is introduced in this way, the problem of how to ensure the loss, delay, and timing of the message will also be introduced, which may cause data inconsistency.
相比于图8-图9的数据更新方式,图4的实施例通过订阅数据库操作更新的Binlog日志,可以实时得到数据库的跟踪操作。基于发布订阅的消息中间件系统进行解耦,不侵入业务系统实现一些功能。通过线程A进行写操作,利用日志中间件(Canal)将消息实时写入MQ(Kafka、racketmq);通过缓存模块订阅消息队列的消息来更新缓存,如果失败,还可以利用重试机制重复更新,直至消息更新成功。使用重试机制可以提高缓存更新概率,不会因为一次失败导致缓存不再更新。并且,利用消息队列的消息时序性,不会出现更新缓存的乱序问题,可以解决多线程更新,数据库时序性问题。Compared with the data update method of Figures 8-9, the embodiment of Figure 4 can obtain the tracking operation of the database in real time by subscribing to the Binlog log updated by the database operation. The message middleware system based on publish-subscribe is decoupled and some functions are implemented without intruding the business system. Write operations are performed through thread A, and the log middleware (Canal) is used to write messages to MQ (Kafka, racketmq) in real time; subscribe to the message queue message through the cache module to update the cache. If it fails, the retry mechanism can be used to repeat the update until the message is successfully updated. The use of the retry mechanism can increase the probability of cache updates, and the cache will not be updated again due to a single failure. In addition, by utilizing the message timing of the message queue, there will be no disorder in updating the cache, and the multi-threaded update and database timing problems can be solved.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本公开各个实施例的方法。Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present disclosure.
图10是根据本公开实施例的一种数据更新装置的结构框图;如图10所示,包括:FIG10 is a structural block diagram of a data updating device according to an embodiment of the present disclosure; as shown in FIG10 , the device comprises:
第一更新模块92,设置为获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;A first update module 92, configured to obtain an update identifier corresponding to the log content of the first database, wherein the update identifier is used to indicate whether the log content of the first database has been updated;
需要说明的是,上述更新标识可以表示整个第一数据库的日志内容是否更新,也可以表示第一数据库内的指定数据的日志内容是否更新,本公开对此不作限制。It should be noted that the above update flag may indicate whether the log content of the entire first database is updated, or may indicate whether the log content of specified data in the first database is updated, and the present disclosure does not impose any limitation on this.
获取模块94,设置为在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;An acquisition module 94 is configured to acquire the second data from the first database when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, wherein the first data and the second data correspond to the same data identifier;
其中,上述数据标识可以理解为识别数据值的唯一标识,例如键值对形式中,可以将数据标识理解为键,将数据标识对应的数据理解为值。具体的,例如以数据标识以键A为例,以第一数据为数据A1为例,以第二数据为A2为例,则第一数据对应于键A可以表示为{A,A1},当第一数据更新为第二数据之后,第二数据对应于键A可以表示为{A,A2}。The above data identifier can be understood as a unique identifier for identifying a data value. For example, in the form of a key-value pair, the data identifier can be understood as a key, and the data corresponding to the data identifier can be understood as a value. Specifically, for example, taking the data identifier as key A, the first data as data A1, and the second data as A2, the first data corresponding to key A can be expressed as {A, A1}. When the first data is updated to the second data, the second data corresponding to key A can be expressed as {A, A2}.
第二更新模块96,设置为确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。The second updating module 96 is configured to determine the first data stored in the cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
通过上述装置,获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据,解决了相关技术中,如何对缓存数据进行更新,以保证数据库中数据和缓存数据一致的技术问题,进而在对缓存数据进行更新时,能够保证数据库中数据和缓存数据一致。Through the above-mentioned device, an update identifier corresponding to the log content of the first database is obtained, and the update identifier is used to indicate whether the log content of the first database has been updated; when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, the second data is obtained from the first database, wherein the first data and the second data correspond to the same data identifier; the first data stored in the cache is determined, and the first data stored in the cache is updated to the second data, wherein the cache and the first database have pre-synchronized the first data, which solves the technical problem in the related art of how to update the cache data to ensure that the data in the database and the cache data are consistent, and further when the cache data is updated, it can ensure that the data in the database and the cache data are consistent.
在一个示例性实施例中,上述数据更新装置还包括:确定模块,设置为在获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,根据所述ACK标识确定第一查询指令;基于所述第一查询指令从第二数据库查询到第三数据,所述第二数据库为所述第一数据库的备份数据库,所述第三数据表示所述第二数据的备份数据;在确定所述第二数据和所述第三数据一致的情况下,向终端设备发送用于表示更新成功的通知消息。In an exemplary embodiment, the above-mentioned data update device also includes: a determination module, which is configured to determine a first query instruction according to an update confirmation ACK identifier generated when the cache updates the first data to the second data; based on the first query instruction, query third data from a second database, the second database is a backup database of the first database, and the third data represents the backup data of the second data; when it is determined that the second data and the third data are consistent, send a notification message to the terminal device to indicate that the update is successful.
在一个实施例中,在未获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,可以确定上述缓存没有成功更新,则 基于重试机制重新更新缓存,并向终端设备发送用于表示重新更新的重试消息,其中,更新失败的原因可以包括断网、程序错误、由于无足够存储空间导致程序运行失败等,本公开不限于此。In one embodiment, if the update confirmation ACK identifier generated when the cache updates the first data to the second data is not obtained, it can be determined that the above cache has not been successfully updated, then the cache is re-updated based on a retry mechanism, and a retry message indicating the re-update is sent to the terminal device, wherein the reasons for the update failure may include network disconnection, program error, program failure due to insufficient storage space, etc., but the present disclosure is not limited to this.
或者,在未获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,直接将所述缓存中保存的第一数据更新为所述第三数据。Alternatively, when an update confirmation ACK identifier generated when the cache updates the first data to the second data is not obtained, the first data stored in the cache is directly updated to the third data.
在其他实施例中,在确定所述第二数据和所述第三数据不一致的情况下,删除缓存内的第二数据,将所述缓存中保存的第一数据更新为所述第三数据。In other embodiments, when it is determined that the second data and the third data are inconsistent, the second data in the cache is deleted, and the first data stored in the cache is updated to the third data.
在一个示例性实施例中,上述第二更新模块96还设置为确定将所述第一数据库的第二数据备份至所述第二数据库的备份时间;根据所述备份时间生成用于延迟缓存删除操作的延时队列,其中,所述延时队列对应有延时执行时间,所述延时执行时间的开始时刻为所述第一数据库中的第一数据变更为第二数据的变更时刻,所述延时执行时间的结束时刻晚于所述备份时间的结束时刻;根据所述延时队列对应的延时执行时间将所述缓存中保存的第一数据更新为所述第二数据。In an exemplary embodiment, the second update module 96 is further configured to determine a backup time for backing up the second data of the first database to the second database; generate a delay queue for delaying cache deletion operations according to the backup time, wherein the delay queue corresponds to a delayed execution time, the start time of the delayed execution time is the change time when the first data in the first database is changed to the second data, and the end time of the delayed execution time is later than the end time of the backup time; and update the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue.
在一个示例性实施例中,上述第二更新模块96还设置为经过所述延时执行时间之后,基于所述缓存删除操作将所述缓存中的第一数据删除;从所述第二数据库内读取第三数据,并将所述第三数据写入所述缓存。In an exemplary embodiment, the second update module 96 is further configured to delete the first data in the cache based on the cache deletion operation after the delayed execution time; read the third data from the second database, and write the third data into the cache.
在一个示例性实施例中,上述第二更新模块96还设置为确定将所述第一数据库中的第二数据备份至第二数据库时的历史备份时间,基于所述历史备份时间确定所述备份时间,包括以下之一:将使用时间最长的历史备份时间设置为所述备份时间;将使用频次最高的历史备份时间设置为所述备份时间;将使用时间最新的历史备份时间设置为所述备份时间。In an exemplary embodiment, the second update module 96 is further configured to determine the historical backup time when backing up the second data in the first database to the second database, and to determine the backup time based on the historical backup time, including one of the following: setting the historical backup time with the longest usage time as the backup time; setting the historical backup time with the highest usage frequency as the backup time; setting the historical backup time with the latest usage time as the backup time.
其中,基于所述历史备份时间确定所述备份时间还可以包括基于多个所述历史备份时间的均值确定所述备份时间。Wherein, determining the backup time based on the historical backup time may further include determining the backup time based on an average of a plurality of the historical backup times.
在一个示例性实施例中,上述第二更新模块96还设置为根据所述第一数据 库的类型、所述第二数据库的类型和所述第一数据库中的第二数据备份至第二数据库时的网络状态确定将所述第一数据库中的第二数据备份至第二数据库时的备份时间,以根据所述备份时间确定将所述第一数据库中的第二数据备份至第二数据库。In an exemplary embodiment, the second update module 96 is further configured to determine a backup time for backing up the second data in the first database to the second database based on the type of the first database, the type of the second database, and the network status when the second data in the first database is backed up to the second database, so as to determine the backup time for backing up the second data in the first database to the second database based on the backup time.
在一个示例性实施例中,上述数据更新装置还包括:发送模块,设置为在确定所述第一数据库、所述第二数据库和所述缓存中均查询不到所述第一数据的情况下,向终端设备发送用于表示更新成功的通知消息;或者,在确定所述第一数据库和所述缓存中均查询到所述第二数据的情况下,向终端设备发送用于表示更新成功的通知消息;或者,在确定所述第二数据库和所述缓存中均查询到第三数据的情况下,向终端设备发送用于表示更新成功的通知消息。In an exemplary embodiment, the above-mentioned data update device also includes: a sending module, which is configured to send a notification message indicating a successful update to a terminal device when it is determined that the first data cannot be found in the first database, the second database and the cache; or, when it is determined that the second data is found in both the first database and the cache, send a notification message indicating a successful update to the terminal device; or, when it is determined that the third data is found in both the second database and the cache, send a notification message indicating a successful update to the terminal device.
本公开的实施例还提供了一种存储介质,该存储介质包括存储的程序,其中,上述程序运行时执行上述任一项的方法。An embodiment of the present disclosure further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的程序代码:Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:
S1,获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;S1, obtaining an update identifier corresponding to the log content of the first database, where the update identifier is used to indicate whether the log content of the first database has been updated;
S2,在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;S2, when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, obtaining the second data from the first database, wherein the first data and the second data correspond to the same data identifier;
S3,确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。S3, determining the first data stored in the cache, and updating the first data stored in the cache to the second data, wherein the cache and the first database have synchronized the first data in advance.
本公开的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。Optionally, the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
S1,获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;S1, obtaining an update identifier corresponding to the log content of the first database, where the update identifier is used to indicate whether the log content of the first database has been updated;
S2,在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;S2, when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, obtaining the second data from the first database, wherein the first data and the second data correspond to the same data identifier;
S3,确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。S3, determining the first data stored in the cache, and updating the first data stored in the cache to the second data, wherein the cache and the first database have synchronized the first data in advance.
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
可选地,本实施例中的具体示例可以参考上述实施例及可选实施方式中所描述的示例,本实施例在此不再赘述。Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
显然,本领域的技术人员应该明白,上述的本公开的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本公开不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present disclosure can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present disclosure is not limited to any specific combination of hardware and software.
以上所述仅是本公开的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本公开原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本公开的保护范围。The above is only a preferred embodiment of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present disclosure. These improvements and modifications should also be regarded as the protection scope of the present disclosure.

Claims (16)

  1. 一种数据更新方法,包括:A data updating method, comprising:
    获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;Obtaining an update flag corresponding to the log content of the first database, where the update flag is used to indicate whether the log content of the first database has been updated;
    在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;When it is determined that the update identifier indicates that the first data in the first database is changed to the second data, acquiring the second data from the first database, wherein the first data and the second data correspond to the same data identifier;
    确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。Determine first data stored in a cache, and update the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
  2. 根据权利要求1所述的数据更新方法,其中,在将所述缓存中保存的第一数据更新为所述第二数据之后,所述方法还包括:The data updating method according to claim 1, wherein, after updating the first data stored in the cache to the second data, the method further comprises:
    在获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,根据所述ACK标识确定第一查询指令;In a case where an update confirmation ACK identifier generated when the cache updates the first data to the second data is obtained, determining a first query instruction according to the ACK identifier;
    基于所述第一查询指令从第二数据库查询到第三数据,所述第二数据库为所述第一数据库的备份数据库,所述第三数据表示所述第二数据的备份数据;querying third data from a second database based on the first query instruction, where the second database is a backup database of the first database, and the third data represents backup data of the second data;
    在确定所述第二数据和所述第三数据一致的情况下,向终端设备发送用于表示更新成功的通知消息。When it is determined that the second data and the third data are consistent, a notification message indicating that the update is successful is sent to the terminal device.
  3. 根据权利要求1所述的数据更新方法,其中,将所述缓存中保存的第一数据更新为所述第二数据,包括:The data updating method according to claim 1, wherein updating the first data stored in the cache to the second data comprises:
    确定将所述第一数据库的第二数据备份至所述第二数据库的备份时间;Determining a backup time for backing up the second data of the first database to the second database;
    根据所述备份时间生成用于延迟缓存删除操作的延时队列,其中,所述延时队列对应有延时执行时间,所述延时执行时间的开始时刻为所述第一数据库中的第一数据变更为第二数据的变更时刻,所述延时执行时间的结束时刻晚于所述备份时间的结束时刻;Generate a delay queue for delaying cache deletion operations according to the backup time, wherein the delay queue corresponds to a delay execution time, the start time of the delay execution time is the change time when the first data in the first database is changed to the second data, and the end time of the delay execution time is later than the end time of the backup time;
    根据所述延时队列对应的延时执行时间将所述缓存中保存的第一数据更新为所述第二数据。The first data stored in the cache is updated to the second data according to the delayed execution time corresponding to the delay queue.
  4. 根据权利要求3所述的数据更新方法,其中,根据所述延时队列对应的延时执行时间将所述缓存中保存的第一数据更新为所述第二数据,包括:The data updating method according to claim 3, wherein updating the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue comprises:
    在经过所述延时执行时间之后,基于所述缓存删除操作将所述缓存中的第一数据删除;After the delayed execution time has elapsed, deleting the first data in the cache based on the cache deletion operation;
    从所述第二数据库内读取第三数据,并将所述第三数据写入所述缓存。Read third data from the second database, and write the third data into the cache.
  5. 根据权利要求3所述的数据更新方法,其中,确定将所述第一数据库的第二数据备份至所述第二数据库的备份时间,包括:The data updating method according to claim 3, wherein determining the backup time for backing up the second data of the first database to the second database comprises:
    确定将所述第一数据库中的第二数据备份至第二数据库时的历史备份时间,基于所述历史备份时间确定所述备份时间,包括以下之一:Determining a historical backup time when backing up the second data in the first database to the second database, and determining the backup time based on the historical backup time, includes one of the following:
    将使用时间最长的历史备份时间设置为所述备份时间;Setting the longest historical backup time as the backup time;
    将使用频次最高的历史备份时间设置为所述备份时间;Setting the most frequently used historical backup time as the backup time;
    将使用时间最新的历史备份时间设置为所述备份时间。The historical backup time with the latest usage time is set as the backup time.
  6. 根据权利要求3所述的数据更新方法,其中,确定将所述第一数据库中的第二数据备份至第二数据库时所需的备份时间,包括:The data updating method according to claim 3, wherein determining the backup time required to back up the second data in the first database to the second database comprises:
    根据所述第一数据库的类型、所述第二数据库的类型和所述第一数据库中的第二数据备份至第二数据库时的网络状态确定将所述第一数据库中的第二数据备份至第二数据库时的备份时间,以根据所述备份时间确定将所述第一数据库中的第二数据备份至第二数据库。Determine the backup time for backing up the second data in the first database to the second database according to the type of the first database, the type of the second database and the network status when the second data in the first database is backed up to the second database, so as to determine the backup time for backing up the second data in the first database to the second database.
  7. 根据权利要求2所述的数据更新方法,其中,所述方法还包括:The data updating method according to claim 2, wherein the method further comprises:
    在确定所述第一数据库、所述第二数据库和所述缓存中均查询不到所述第一数据的情况下,向终端设备发送用于表示更新成功的通知消息;When it is determined that the first data cannot be found in the first database, the second database, and the cache, sending a notification message indicating that the update is successful to the terminal device;
    或者,在确定所述第一数据库和所述缓存中均查询到所述第二数据的情况 下,向终端设备发送用于表示更新成功的通知消息;Alternatively, when it is determined that the second data is found in both the first database and the cache, a notification message indicating that the update is successful is sent to the terminal device;
    或者,在确定所述第二数据库和所述缓存中均查询到第三数据的情况下,向终端设备发送用于表示更新成功的通知消息。Alternatively, when it is determined that the third data is found in both the second database and the cache, a notification message indicating that the update is successful is sent to the terminal device.
  8. 一种数据更新装置,包括:A data updating device, comprising:
    第一更新模块,设置为获取第一数据库的日志内容对应的更新标识,所述更新标识用于表示所述第一数据库的日志内容是否发生了更新;A first update module, configured to obtain an update identifier corresponding to the log content of the first database, wherein the update identifier is used to indicate whether the log content of the first database has been updated;
    获取模块,设置为在确定所述更新标识指示所述第一数据库中的第一数据变更为第二数据的情况下,从所述第一数据库中获取所述第二数据,其中,所述第一数据和所述第二数据对应于同一数据标识;an acquisition module, configured to acquire the second data from the first database when it is determined that the update identifier indicates that the first data in the first database is changed to the second data, wherein the first data and the second data correspond to the same data identifier;
    第二更新模块,设置为确定缓存中保存的第一数据,并将所述缓存中保存的第一数据更新为所述第二数据,其中,所述缓存与所述第一数据库已预先同步所述第一数据。The second updating module is configured to determine the first data stored in the cache and update the first data stored in the cache to the second data, wherein the cache and the first database have pre-synchronized the first data.
  9. 根据权利要求8所述的数据更新装置,其中,所述确定模块,设置为在获取到所述缓存将所述第一数据更新为所述第二数据时所生成的更新确认ACK标识的情况下,根据所述ACK标识确定第一查询指令;基于所述第一查询指令从第二数据库查询到第三数据,所述第二数据库为所述第一数据库的备份数据库,所述第三数据表示所述第二数据的备份数据;在确定所述第二数据和所述第三数据一致的情况下,向终端设备发送用于表示更新成功的通知消息。According to the data updating device according to claim 8, wherein the determining module is configured to determine a first query instruction according to an update confirmation ACK identifier generated when the cache updates the first data to the second data, upon obtaining the ACK identifier; query third data from a second database based on the first query instruction, the second database is a backup database of the first database, and the third data represents backup data of the second data; and send a notification message indicating that the update is successful to the terminal device when it is determined that the second data and the third data are consistent.
  10. 根据权利要求8所述的数据更新装置,其中,所述第二更新模块96还设置为确定将所述第一数据库的第二数据备份至所述第二数据库的备份时间;根据所述备份时间生成用于延迟缓存删除操作的延时队列,其中,所述延时队列对应有延时执行时间,所述延时执行时间的开始时刻为所述第一数据库中的第一数据变更为第二数据的变更时刻,所述延时执行时间的结束时刻晚于所述备份时间的结束时刻;根据所述延时队列对应的延时执行时间将所述缓存中保存的第一数据更新为所述第二数据。According to the data updating device of claim 8, wherein the second updating module 96 is further configured to determine a backup time for backing up the second data of the first database to the second database; generate a delay queue for delaying the cache deletion operation according to the backup time, wherein the delay queue corresponds to a delayed execution time, the start time of the delayed execution time is the change time when the first data in the first database is changed to the second data, and the end time of the delayed execution time is later than the end time of the backup time; and update the first data stored in the cache to the second data according to the delayed execution time corresponding to the delay queue.
  11. 根据权利要求10所述的数据更新装置,其中,所述第二更新模块96还设置 为经过所述延时执行时间之后,基于所述缓存删除操作将所述缓存中的第一数据删除;从所述第二数据库内读取第三数据,并将所述第三数据写入所述缓存。According to the data updating device of claim 10, wherein the second updating module 96 is further configured to delete the first data in the cache based on the cache deletion operation after the delayed execution time has elapsed; read the third data from the second database, and write the third data into the cache.
  12. 根据权利要求10所述的数据更新装置,其中,所述第二更新模块96还设置为确定将所述第一数据库中的第二数据备份至第二数据库时的历史备份时间,基于所述历史备份时间确定所述备份时间,包括以下之一:将使用时间最长的历史备份时间设置为所述备份时间;将使用频次最高的历史备份时间设置为所述备份时间;将使用时间最新的历史备份时间设置为所述备份时间。According to the data updating device according to claim 10, wherein the second updating module 96 is also configured to determine the historical backup time when backing up the second data in the first database to the second database, and determining the backup time based on the historical backup time includes one of the following: setting the historical backup time with the longest usage time as the backup time; setting the historical backup time with the highest usage frequency as the backup time; setting the historical backup time with the latest usage time as the backup time.
  13. 根据权利要求10所述的数据更新装置,其中,所述第二更新模块96还设置为根据所述第一数据库的类型、所述第二数据库的类型和所述第一数据库中的第二数据备份至第二数据库时的网络状态确定将所述第一数据库中的第二数据备份至第二数据库时的备份时间,以根据所述备份时间确定将所述第一数据库中的第二数据备份至第二数据库。According to the data updating device according to claim 10, wherein the second updating module 96 is also configured to determine the backup time when the second data in the first database is backed up to the second database according to the type of the first database, the type of the second database and the network status when the second data in the first database is backed up to the second database, so as to determine the backup time of the second data in the first database to the second database according to the backup time.
  14. 根据权利要求9所述的数据更新装置,其中,所述数据更新装置还包括:发送模块,设置为在确定所述第一数据库、所述第二数据库和所述缓存中均查询不到所述第一数据的情况下,向终端设备发送用于表示更新成功的通知消息;或者,在确定所述第一数据库和所述缓存中均查询到所述第二数据的情况下,向终端设备发送用于表示更新成功的通知消息;或者,在确定所述第二数据库和所述缓存中均查询到第三数据的情况下,向终端设备发送用于表示更新成功的通知消息。According to the data updating device according to claim 9, the data updating device further includes: a sending module, configured to send a notification message indicating a successful update to a terminal device when it is determined that the first data cannot be found in the first database, the second database and the cache; or, when it is determined that the second data is found in both the first database and the cache, send a notification message indicating a successful update to the terminal device; or, when it is determined that the third data is found in both the second database and the cache, send a notification message indicating a successful update to the terminal device.
  15. 一种计算机可读的存储介质,所述计算机可读的存储介质包括存储的程序,其中,所述程序运行时执行上述权利要求1至7任一项中所述的方法。A computer-readable storage medium, comprising a stored program, wherein the program executes the method described in any one of claims 1 to 7 when executed.
  16. 一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为通过所述计算机程序执行所述权利要求1至7任一项中所述的方法。An electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 through the computer program.
PCT/CN2022/134785 2022-09-29 2022-11-28 Data update method and apparatus, storage medium, and electronic apparatus WO2024066001A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211203452.0A CN115576966A (en) 2022-09-29 2022-09-29 Data updating method and device, storage medium and electronic device
CN202211203452.0 2022-09-29

Publications (1)

Publication Number Publication Date
WO2024066001A1 true WO2024066001A1 (en) 2024-04-04

Family

ID=84582789

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/134785 WO2024066001A1 (en) 2022-09-29 2022-11-28 Data update method and apparatus, storage medium, and electronic apparatus

Country Status (2)

Country Link
CN (1) CN115576966A (en)
WO (1) WO2024066001A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
US20190163776A1 (en) * 2017-11-30 2019-05-30 International Business Machines Corporation Ensuring consistent replication of updates in databases
CN109871388A (en) * 2019-02-19 2019-06-11 北京字节跳动网络技术有限公司 Data cache method, device, whole electronic equipment and storage medium
CN113094378A (en) * 2021-03-19 2021-07-09 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190163776A1 (en) * 2017-11-30 2019-05-30 International Business Machines Corporation Ensuring consistent replication of updates in databases
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
CN109871388A (en) * 2019-02-19 2019-06-11 北京字节跳动网络技术有限公司 Data cache method, device, whole electronic equipment and storage medium
CN113094378A (en) * 2021-03-19 2021-07-09 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN115576966A (en) 2023-01-06

Similar Documents

Publication Publication Date Title
US11023448B2 (en) Data scrubbing method and apparatus, and computer readable storage medium
US7900085B2 (en) Backup coordinator for distributed transactions
US9984140B1 (en) Lease based leader election system
CA2938768C (en) Geographically-distributed file system using coordinated namespace replication
EP2653986B1 (en) Client-side caching of a database transaction token.
WO2017177941A1 (en) Active/standby database switching method and apparatus
US9201919B2 (en) Bandwidth optimized two-phase commit protocol for distributed transactions
US10114848B2 (en) Ensuring the same completion status for transactions after recovery in a synchronous replication environment
US20140089259A1 (en) Operation method and apparatus for data storage system
US9367261B2 (en) Computer system, data management method and data management program
US11544232B2 (en) Efficient transaction log and database processing
WO2012045245A1 (en) Method and system for maintaining data consistency
WO2018010501A1 (en) Global transaction identifier (gtid) synchronization method, apparatus and system, and storage medium
CN109144748B (en) Server, distributed server cluster and state driving method thereof
CN103024065A (en) System configuration management method for cloud storage system
WO2022095366A1 (en) Redis-based data reading method and apparatus, device, and readable storage medium
US20230110826A1 (en) Log execution method and apparatus, computer device and storage medium
CN110417882B (en) Method and device for determining main node and storage medium
CN108140035B (en) Database replication method and device for distributed system
CN108090056B (en) Data query method, device and system
US20060282524A1 (en) Apparatus, system, and method for facilitating communication between an enterprise information system and a client
US9424362B2 (en) Storing and publishing contents of a content store
WO2024066001A1 (en) Data update method and apparatus, storage medium, and electronic apparatus
Deftu et al. A scalable conflict-free replicated set data type
CN112711466B (en) Hanging affair inspection method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22960598

Country of ref document: EP

Kind code of ref document: A1