CN110413684B - Database synchronization method, device and system - Google Patents

Database synchronization method, device and system Download PDF

Info

Publication number
CN110413684B
CN110413684B CN201810380155.0A CN201810380155A CN110413684B CN 110413684 B CN110413684 B CN 110413684B CN 201810380155 A CN201810380155 A CN 201810380155A CN 110413684 B CN110413684 B CN 110413684B
Authority
CN
China
Prior art keywords
database
file
type
storage device
category
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810380155.0A
Other languages
Chinese (zh)
Other versions
CN110413684A (en
Inventor
范烈严
冯广欣
孙承华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Haikang Storage Technology Co ltd
Original Assignee
Hangzhou Haikang Storage Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Haikang Storage Technology Co ltd filed Critical Hangzhou Haikang Storage Technology Co ltd
Priority to CN201810380155.0A priority Critical patent/CN110413684B/en
Publication of CN110413684A publication Critical patent/CN110413684A/en
Application granted granted Critical
Publication of CN110413684B publication Critical patent/CN110413684B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides a database synchronization method, device and system. The method comprises the following steps: the terminal equipment sends a data acquisition request aiming at a database in the storage equipment to the storage equipment; the storage equipment receives the data acquisition request sent by the terminal equipment, determines first type target files aiming at the data acquisition request from all stored first type database files, and sends the first type target files to the terminal equipment; the method comprises the steps that terminal equipment receives a first type of target file sent by storage equipment, and a database in the terminal equipment is updated according to the first type of target file; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file. By applying the scheme provided by the embodiment of the application, the time consumption of the database synchronization process can be shortened, and the efficiency is improved.

Description

Database synchronization method, device and system
Technical Field
The present invention relates to the field of data transmission technologies, and in particular, to a database synchronization method, device, and system.
Background
With the development of technology, users can use terminal devices to take pictures, record video and other operations, and the amount of data generated in the terminal devices is increasing. The user may choose to store the user data in the terminal device in a storage device, such as a server, in order to reduce the amount of data in the terminal device. The user can view and modify the user data stored in the storage device through the terminal device. The data interaction between the terminal device and the storage device is frequent.
In order to facilitate the user to select to view the data such as the image or the video stored in the storage device, the terminal device needs to synchronize the local database with the database in the storage device, that is, the terminal device needs to acquire the database data in the storage device. Specifically, the terminal device may acquire address information for storing data such as images or videos from a database of the storage device, store the acquired data to a local database of the terminal device, and display the data to the user for the user to select. The terminal device can download corresponding image or video data from the storage device according to the selection of the user.
When receiving a database data acquisition request sent by the terminal device, the storage device can determine a search condition, search corresponding database data from the database of the storage device according to the search condition, and send the searched database data to the terminal device.
The synchronization method can realize the synchronization of the database in the storage device to the terminal device. However, when the data amount of the user data stored in the storage device is very large, the data entries of the database in the storage device are also very large, and it takes a long time for the storage device to retrieve and obtain the database data from the database after receiving the data acquisition request of the terminal device. In this way, it takes a long time from the time when the terminal device transmits the data acquisition request to the time when the terminal device receives the database data transmitted from the storage device, that is, the synchronization time of the database is long, and the efficiency is low.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method, an apparatus, and a system for database synchronization, so as to shorten the time consumption of the database synchronization process and improve the efficiency.
To achieve the above object, an embodiment of the present application provides a database synchronization method, which is applied to a storage device, and includes:
receiving a data acquisition request aiming at a database in the storage device, which is sent by a terminal device;
determining a first type object file aiming at the data acquisition request from the stored first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
Optionally, the step of determining a first type object file for the data acquisition request from the stored first type database files includes:
determining a first type target file aiming at the data acquisition request from all stored first type database files according to time information which is carried by the data acquisition request and is used for representing the last acquisition of the database files from the storage equipment; or alternatively, the process may be performed,
Determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: and the storage device receives the time of the data acquisition request sent by the terminal device.
Optionally, the storage device is further configured to store each second type of database file, where each second type of database file includes all data of the database in the storage device when the second type of database file is generated;
the data acquisition request carries the category of the database file; the step of determining a first type object file for the data acquisition request from the stored first type database files includes:
when the category is the category of the first-class database file, determining a first-class target file aiming at the data acquisition request from the first-class database file;
the method further comprises the steps of:
when the category is the category of the second-class database file, determining a second-class target file aiming at the data acquisition request from the stored second-class database files; and sending the second type target file to the terminal equipment so that the terminal equipment stores all pieces of data in the second type target file into a database in the terminal equipment.
Optionally, the step of determining the second class object file for the data acquisition request from the stored second class database files includes:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
Optionally, the second class database file is generated in the following manner:
when the generation conditions of the preset second class database file are met, determining the retrieval conditions of all data of the database in the storage equipment;
and according to the retrieval conditions, acquiring each piece of data from the database of the storage equipment, and generating a second class database file from each piece of data.
Optionally, the generating conditions of the second class database file include:
the data change amount of the database in the storage device is larger than a preset change amount threshold; alternatively, the preset generation period arrives.
Optionally, the first type database file is generated in the following manner:
determining data change information for a database in the storage device; and generating a first type database file containing the data change information.
The embodiment of the application also provides another database synchronization method, which is applied to the terminal equipment and comprises the following steps:
Sending a data acquisition request for a database in the storage device to the storage device;
receiving a first type target file sent by the storage equipment; the first type of target files are as follows: the storage device determines database files aiming at the data acquisition request from all stored first-type database files; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and updating the database in the terminal equipment according to the first type of target file.
Optionally, the method further comprises:
receiving a second type object file sent by the storage equipment; wherein the second class of object files are: the storage device determines a database file aiming at the data acquisition request from the stored second class database files; each second class database file contains all data of the database in the storage device when the second class database file is generated;
and storing each piece of data in the second type of target file into a database in the terminal equipment.
Optionally, the data acquisition request carries a category of the database file to be acquired; the category is determined in the following way:
When the data acquisition request is a data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the second category database file; when the data acquisition request is not the data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when a database is not established in the terminal equipment, determining the category as the category of the second-class database file; when a database is established in the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than the preset time length threshold, determining the category as the category of the first-type database file;
when determining that the category is a category of the first category database file, the method further includes:
And acquiring time information of the database file acquired from the storage device last time, and adding the time information into the data acquisition request.
Optionally, after updating the database in the terminal device, the method further comprises: and displaying each piece of data of the database in the terminal equipment.
The embodiment of the application also provides a database synchronization device, which is applied to a storage device, and comprises:
the first receiving module is used for receiving a data acquisition request aiming at a database in the storage device, which is sent by the terminal device;
the first determining module is used for determining a first type target file aiming at the data acquisition request from the stored first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and the first sending module is used for sending the first target file to the terminal equipment so that the terminal equipment can update the database in the terminal equipment according to the first type of target file.
Optionally, the first determining module is specifically configured to:
Determining a first type target file aiming at the data acquisition request from all stored first type database files according to time information which is carried by the data acquisition request and is used for representing the last acquisition of the database files from the storage equipment; alternatively, the first determining module is specifically configured to:
determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: and the storage device receives the time of the data acquisition request sent by the terminal device.
Optionally, the storage device is further configured to store each second type of database file, where each second type of database file includes all data of the database in the storage device when the second type of database file is generated;
the data acquisition request carries the category of the database file; the first determining module is specifically configured to:
when the category is the category of the first-class database file, determining a first-class target file aiming at the data acquisition request from the stored first-class database files;
The first determining module is further configured to:
when the category is the category of the second-class database file, determining a second-class target file aiming at the data acquisition request from the stored second-class database files;
the first sending module is further configured to:
and sending the second type target file to the terminal equipment so that the terminal equipment stores all pieces of data in the second type target file into a database in the terminal equipment.
Optionally, the first determining module is specifically configured to:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
Optionally, the apparatus further includes:
the first generation module is used for determining the retrieval conditions of all data of the database in the storage device when the generation conditions of the preset second class database file are met, acquiring all data from the database of the storage device according to the retrieval conditions, and generating the second class database file by all data.
Optionally, the generating conditions of the second class database file include:
the data change amount of the database in the storage device is larger than a preset change amount threshold; alternatively, the preset generation period arrives.
Optionally, the apparatus further includes:
and the second generation module is used for determining data change information aiming at the database in the storage device and generating a first-class database file containing the data change information.
The embodiment of the application provides another database synchronization device, which is applied to terminal equipment, and comprises the following components:
the second sending module is used for sending a data acquisition request aiming at a database in the storage device to the storage device;
the second receiving module is used for receiving the first type target files sent by the storage equipment; wherein, the target database file is: the storage device determines database files aiming at the data acquisition request from all stored first-type database files; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and the second updating module is used for updating the database in the terminal equipment according to the first type of target file.
Optionally, the apparatus further includes: a storage module;
the second receiving module is also used for receiving a second class object file sent by the storage equipment; wherein the second class of object files are: the storage device determines database files aiming at the data acquisition request from the stored second class database files, and each second class database file contains all data of a database in the storage device when the second class database file is generated;
And the storage module is used for storing each piece of data in the second type of target file into a database in the terminal equipment.
Optionally, the data acquisition request carries a category of the database file to be acquired; the apparatus further comprises:
a third determining module, configured to determine a category of the database file to be acquired;
the third determining module is specifically configured to:
when the data acquisition request is a data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the second category database file; when the data acquisition request is not the data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when a database is not established in the terminal equipment, determining the category as the category of the second-class database file; when a database is established in the terminal equipment, determining the category as the category of the second category database file; or alternatively, the process may be performed,
when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than the preset time length threshold, determining the category as the category of the first-type database file;
The apparatus further comprises:
and the acquisition module is used for acquiring time information of the database file acquired from the storage device last time when the category is determined to be the category of the first-category database file, and adding the time information into the data acquisition request.
Optionally, the apparatus further includes:
and the display module is used for displaying each piece of data of the database in the terminal equipment after updating the database in the terminal equipment.
The embodiment of the application provides a database synchronization system, which comprises: a storage device and a terminal device;
the terminal equipment is used for sending a data acquisition request aiming at a database in the storage equipment to the storage equipment;
the storage device is used for receiving a data acquisition request aiming at a database in the storage device, which is sent by the terminal device, determining a first type target file aiming at the data acquisition request from stored first type database files, and sending the first type target file to the terminal device; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
The terminal equipment is used for receiving the first type of target files sent by the storage equipment and updating the database in the terminal equipment according to the first type of target files.
Optionally, the storage device is specifically configured to:
determining a first type target file aiming at the data acquisition request from the stored second type database files according to the time information which is carried by the data acquisition request and is used for representing the last acquisition of the database files from the storage device; alternatively, the storage device is specifically configured to:
determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: and the terminal equipment sends the time of the data acquisition request to the storage equipment.
Optionally, the storage device is further configured to store each second class database file; each second class database file contains all data of the database in the storage device when the second class database file is generated;
The data acquisition request carries the category of the database file; the storage device is specifically configured to:
when the category is the category of the first-class database file, determining a first-class target file aiming at the data acquisition request from the stored first-class database files;
the storage device is further configured to:
when the category is the category of the second class database file, determining a second class target file aiming at the data acquisition request from the stored second class database files, and sending the second class target file to the terminal equipment;
the terminal device is specifically configured to:
and receiving a second type of target file sent by the storage device, and storing each piece of data in the second type of target file into a database in the terminal device.
Optionally, the storage device is specifically configured to:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
The embodiment of the application provides a storage device, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
A memory for storing a computer program;
and the processor is used for realizing the database synchronization method provided by the embodiment of the application when executing the program stored in the memory. The method comprises the following steps:
receiving a data acquisition request aiming at a database in the storage device, which is sent by a terminal device;
determining a first type object file aiming at the data acquisition request from the stored first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
The embodiment of the application provides terminal equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface, and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the database synchronization method provided by the embodiment of the application when executing the program stored in the memory. The method comprises the following steps:
Sending a data acquisition request for a database in the storage device to the storage device;
receiving a first type target file sent by the storage equipment; the first type of target files are as follows: the storage device determines database files aiming at the data acquisition request from all stored first-type database files; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and updating the database in the terminal equipment according to the first type of target file.
The embodiment of the application provides a computer readable storage medium, and a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the database synchronization method provided by the embodiment of the application is realized. The method comprises the following steps:
receiving a data acquisition request aiming at a database in the storage device, which is sent by a terminal device;
determining a first type object file aiming at the data acquisition request from the stored first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
And sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
The embodiment of the application provides a computer readable storage medium, and a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the database synchronization method provided by the embodiment of the application is realized. The method comprises the following steps:
sending a data acquisition request for a database in the storage device to the storage device;
receiving a first type target file sent by the storage equipment; the first type of target files are as follows: the storage device determines database files aiming at the data acquisition request from all stored first-type database files; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and updating the database in the terminal equipment according to the first type of target file.
In the database synchronization method, device and system provided by the embodiment of the application, the storage device can determine the first type of target files from the stored first type of database files when receiving the data acquisition request sent by the terminal device, send the first type of target files to the terminal device, and the terminal device updates the database in the terminal device according to the first type of target files. Because each first-class database file contains the data change information of the database in the storage device, when a data acquisition request is received, the storage device does not need to obtain data from the database in a database searching mode and send the data to the terminal device, but can directly send the stored first-class database file to the terminal device so as to realize the synchronization of the database to the terminal device, so that the time consumption of a database synchronization process can be shortened, and the efficiency is improved. Of course, not all of the above-described advantages need be achieved simultaneously in practicing any one of the products or methods of the present application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following description will make a brief introduction to the drawings used in the description of the embodiments or the prior art. It is apparent that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
Fig. 1 is a schematic flow chart of a database synchronization method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of another database synchronization method according to an embodiment of the present disclosure;
fig. 3 is a timing chart of the same synchronization database of the terminal device according to the embodiment of the present application;
fig. 4 is a schematic diagram of an interaction flow between a terminal device and a storage device according to an embodiment of the present application;
FIG. 5 is a flowchart of another database synchronization method according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a database synchronization device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of another database synchronization device according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a database synchronization system according to an embodiment of the present disclosure;
FIG. 9 is a schematic structural diagram of a memory device according to an embodiment of the present disclosure;
fig. 10 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present application based on the embodiments herein.
In order to shorten the time consumption of a database synchronization process and improve the efficiency, the embodiment of the application provides a database synchronization method, device and system. The present application will be described in detail with reference to specific examples.
Fig. 1 is a flowchart of a database synchronization method according to an embodiment of the present application. The method is applied to a storage device. The storage device may be a server or may be a computer that can store data other than a server. The server may be a cloud server. The method comprises the following steps of S101 to S103:
Step S101: and receiving a data acquisition request aiming at a database in the storage device, wherein the data acquisition request is sent by the terminal device.
Wherein the database comprises a plurality of pieces of data. The data in the database may be various types of data, for example, may be image, video, audio, or document types of data.
The terminal device may send a data acquisition request for a database in the storage device to the storage device after detecting an input operation by the user.
The data acquisition request may carry at least one of time information, account information, and the like.
One or more databases and the corresponding relation between each database and account information can be stored in the storage device. When the storage device receives a data acquisition request sent by the terminal device, a database corresponding to the account information can be determined according to the account information carried by the data acquisition request and the corresponding relation between each stored database and the account information, wherein the database is a database corresponding to the data acquisition request, namely, a database of which the terminal device wants to acquire data.
Step S102: a first type of object file for the data acquisition request is determined from the stored first database files.
Each stored first-type database file contains data change information of a database in storage equipment corresponding to the generation time of the first-type database file. The first type of database file is a pre-generated file. The data change information contained by the different first type database files may be different. The data change information may include data representing an update operation of the database and update contents. For example, the data change information may include: database added data, deleted data, modified data, etc.
When the first type target file is determined from the stored first type database files, the first type target file can be determined from the first type database files according to the generation time of the first type database files and the time information carried in the data acquisition request.
Step S103: and sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
The storage device sends the first type of target file to the terminal device, and the terminal device can receive the first type of target file sent by the storage device and update the database in the terminal device according to the first type of target file so as to realize data synchronization of the database in the terminal device and the database in the storage device.
When the first type object file is sent, the first type object file can be converted into a structured network data format, and the first type object file is sent to the terminal equipment in the form of the network data format.
The structured network data format may include characters of a protocol header, a protocol trailer, etc. of a network transport protocol (e.g., http). The first type of object file is converted into a structured network data format, and a protocol header character, a protocol tail character and the like can be added into the first type of object file. Thus, after the first type target file is determined, the first type target file can be transmitted.
As can be seen from the foregoing, in this embodiment, the storage device may determine the first type object file from the stored first type database files when receiving the data acquisition request sent by the terminal device, send the first type object file to the terminal device, and update the database in the terminal device according to the first type object file by the terminal device. Because each first-class database file contains the data change information of the database in the storage device, when a data acquisition request is received, the storage device does not need to obtain data from the database in a database searching mode and send the data to the terminal device, but can directly send the stored first-class database file to the terminal device so as to realize the synchronization of the database to the terminal device, so that the time consumption of a database synchronization process can be shortened, and the efficiency is improved. In addition, the first type target file contains data change information, so that the data volume of the file is small, and the sending time can be saved during sending.
In particular, when the number of data entries in a database in a storage device is large, it takes a lot of time to retrieve data from the database. The files containing the data change information of the database are generated in advance, and the determined database files are directly sent to the terminal equipment, so that a lot of time can be saved.
If the first type database file is not generated when the storage device receives the data acquisition request sent by the terminal device, the data in the storage device database can be directly retrieved, the retrieved data is sent to the terminal device, and each data acquisition request of the terminal device is responded as far as possible.
Fig. 2 is another flow chart of the database synchronization method according to the embodiment of the present application. The method is applied to a storage device. The storage device may be a server or may be a computer that can store data other than a server. The server may be a cloud server. In this embodiment, the storage device is further configured to store each second type database file, where each second type database file includes all data of the database in the storage device when the second type database file is generated. Since the data of the database in the storage device may be changed, for example, the data may be added or subtracted, or the data may be modified, etc., the second type database file containing all the data of the database in the storage device may be generated at different points in time.
The data volume of each first type database file may be less than the data volume of each second type database file. Even more, the data volume of each first type of database file may be much smaller than the data volume of each second type of database file. Much smaller can be understood to be more than ten times smaller, etc.
The present embodiment includes the following steps S201 to S206.
Step S201: and receiving a data acquisition request aiming at a database in the storage device, wherein the data acquisition request is sent by the terminal device.
The step is the same as step S101 in the embodiment shown in fig. 1, and the specific description may refer to the embodiment shown in fig. 1, which is not repeated here.
Step S202: and receiving information which is sent by the terminal equipment and represents the category of the database file to be acquired.
The class of the first type database file and the class of the second type database file may be represented by numerals or letters, for example, a and B are used to represent the class of the first type database file and the class of the second type database file, respectively; alternatively, it is possible to use 1 and 0 for the category of the first type database file and the category of the second type database file, respectively. The embodiments of the present application do not limit the specific format of the category.
The terminal device may send the information carried in a data acquisition request to the storage device, from which the storage device may obtain the information. The method can reduce the number of data transmission times between the devices and improve the data processing efficiency. When the terminal equipment needs to synchronize the database, the terminal equipment can actively send the types of the needed database files to the storage equipment. In this way, the storage device can reduce the amount of data stored without having to record which database files the terminal device has acquired.
The terminal device may also directly send the information to the storage device, and the storage device may directly receive the information. The terminal device may transmit the information before or after transmitting the above-mentioned data acquisition request, which is not particularly limited in this application.
The terminal device may determine the category of the database to be acquired in a number of ways. For example, when the data acquisition request is a data acquisition request that is first sent by the terminal device to the storage device, determining the category as a category of the second-type database file; and when the data acquisition request is not the data acquisition request which is sent to the storage device for the first time by the terminal device, determining the category as the category of the first-type database file.
Or when the database is not established in the terminal equipment, determining the category as the category of the second class database file; when a database is established in the terminal device, the above category is determined as the category of the first category database file. And when the terminal equipment performs the operation of storing all pieces of data in the second class database file into the database of the terminal equipment, the database is considered to be established in the terminal equipment.
Or when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; and when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than a preset time length threshold, determining the category as the category of the first-type database file. The preset duration threshold may be a preset value, for example, may be a value such as 3 days, one week, or one month.
When the terminal device determines that the category is the category of the first-type database file, the terminal device can also acquire time information of the database file acquired from the storage device last time, and send the time information to the storage device. When in transmission, the terminal equipment can add the time information into a data acquisition request, and the time information is transmitted to the storage equipment through the data acquisition request, so that the frequency of transmitting data can be reduced, and the processing efficiency is improved. The time information may be a point in time. The last time the time information of the database file was obtained from the storage device, it is understood that the time information of the database file is obtained from the storage device before the current time and closest to the current time. The time information may be the time of last receiving the database file sent by the storage device, or may be the time of last generating the database file sent by the storage device.
Step S203: when the category is a category of the first-type database file, a first-type target file for the data acquisition request is determined from the stored first-type database files.
In this embodiment, when determining the first type of object file, the storage device may further receive time information of the last database file obtained from the storage device sent by the terminal device, and determine, according to the time information, the first type of object file for the data obtaining request from the stored first type of database files.
Specifically, when the terminal device sends the time information through the data acquisition request, the storage device may parse the data acquisition request to obtain the time information.
When the storage device determines the first type target file for the data acquisition request from the stored first type database files according to the time information, the first type database file with the generation time later than the time information can be determined as the first type target file for the data acquisition request. The first type database file whose generation time is between the time information and the current time may be determined as the first type target file for the data acquisition request. The current time is the time when the storage device receives the data acquisition request sent by the terminal device. In this embodiment, there may be a plurality of first type database files whose time is later than the time information, or the first type database files whose time is between the time information and the current time are generated, and in this case, all of the plurality of first type database files may be used as the first type target files.
Step S204: and sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
The step is the same as step S103 in the embodiment shown in fig. 1, and the specific description may refer to the embodiment shown in fig. 1, which is not repeated here.
Step S205: and when the category is the category of the second-class database file, determining a second-class target file for the data acquisition request from the stored second-class database files.
The method specifically comprises the following steps: and determining the second type database file with the latest generation time as a second type target file for the data acquisition request. The data in the second class database file with the latest generation time is up to date, and the data of the terminal equipment database can be up to date by determining the second class target file in the mode, and the consistency with the data of the database in the storage device is maintained.
For example, the database in the storage device stores second class database files generated on 1 month and 1 day, 1 month and 2 days, and 1 month and 3 days, respectively. When the storage device receives the data acquisition request sent by the terminal device during 1 month and 4 days, the second class database file with the latest generation time of 1 month and 3 days in the stored second class database files can be used as the second class target file.
Step S206: and sending the second type of target file to the terminal equipment so that the terminal equipment covers all pieces of data in the second type of target file in a database in the terminal equipment.
In a specific embodiment, when generating the second class database file, each second class database file may be generated according to a structured network data format. In this way, when the second type object file is transmitted, the transmission format does not need to be converted, and time can be saved.
Therefore, the embodiment can determine the first type of target file from the first type of database file according to the type sent by the terminal equipment, or determine the second type of target file from the second type of database file, so that the database data in the terminal equipment is consistent with the database data in the storage equipment, and the storage equipment is prevented from sending the data of the whole database to the terminal equipment when the terminal equipment requests the data each time, therefore, the data flow transmitted between the equipment can be reduced, unnecessary flow consumption is reduced, and the synchronization process of the database data is further accelerated.
Meanwhile, the storage device can determine the first type of target file or the second type of target file according to the type sent by the terminal device, and the storage device does not need to record the information such as the times and time of sending the data acquisition request by the terminal device and the device identification of the terminal device or determine the first type of target file or the second type of target file according to the information, so that the stored data volume can be reduced, and the processing flow of the storage device is simplified.
In particular, when the number of terminal devices for which the storage device is intended is large (for example, the number reaches several tens to hundreds, even thousands, etc.), the connection process between the storage device and the terminal device is generally stateless. On one hand, when the storage device stores information of a plurality of terminal devices, the management overhead is high; on the other hand, when a subsequent terminal device sends a new data acquisition request, the storage device needs to screen the data of the terminal device from the historical data of numerous terminal devices, and this process also needs to consume time. In this embodiment, the storage device may record only the generation time of each database file, that is, the data change on the storage timeline, so that the storage device only needs to retrieve the database file according to the time information. Therefore, the scheme provided by the embodiment can greatly reduce the stored data quantity, save the storage space resource of the storage device, simplify the processing flow of the storage device and enable the storage device to be more flexible and efficient.
In another embodiment of the present application, when the terminal device does not send information indicating a category of the database file to be acquired to the storage device, the step of determining, by the storage device, a first-type target file for the data acquisition request from the stored respective first-type database files may include:
Judging whether the data acquisition request is a data acquisition request which is sent to the storage device for the first time by the terminal device, if not, determining a first type target file aiming at the data acquisition request from all stored first type database files.
The storage device may determine, according to the stored record information of the data acquisition request of the terminal device, whether the data acquisition request is a data acquisition request sent by the terminal device to the storage device for the first time. The record information of the data acquisition request may include a time of each data acquisition request, where the time may be a receiving time of the data acquisition request received by the storage device, or may be a sending time of the data acquisition request sent by the terminal device carried by the data acquisition request to the storage device.
When the judgment result of the step is no, the database in the terminal equipment can be considered to contain all or part of data of the database in the storage equipment, namely the terminal equipment and the database of the storage equipment are synchronized. In this case, the first type object file may be determined from the first type database file.
When the judgment result is yes, the database in the terminal equipment can be considered to not contain the data of the database in the storage equipment, namely the terminal equipment is not synchronized with the database of the storage equipment, and the terminal equipment does not establish the database yet. In this case, the storage device further performs the steps of:
A second type object file for the data acquisition request is determined from the stored respective second type database files.
In this embodiment, the terminal device does not need to send the type of the database file to be acquired to the storage device, and the storage device determines which type of database file to send to the terminal device according to the recorded information. This way the throughput of the terminal device can be reduced.
In another embodiment of the present application, when determining the first type of object file for the data acquisition request from the stored respective first type of database files, the following implementation may be specifically included:
determining a first time when the terminal equipment sends a data acquisition request to the storage equipment last time, and determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request.
The storage device may record the time at which the terminal device sent the data acquisition request each time. The data acquisition request last sent to the storage device is a data acquisition request satisfying the following conditions: the time of the data acquisition request sent by the terminal equipment is closest to the time of the data acquisition request sent by the terminal equipment and is earlier than the time of the data acquisition request sent by the terminal equipment.
The current time is the time when the storage device receives the data acquisition request sent by the terminal device, that is, the time when the storage device receives the data acquisition request sent by the terminal device.
When a plurality of first type database files exist between the first time and the current time, the plurality of first type database files can be used as first type target files.
According to the method and the device for determining the first type object files, the first type object files can be determined from the first type database files under the condition that the terminal device does not send time information to the storage device, and processing accuracy can be improved.
Embodiments of the present application will be described below with specific examples.
For example, referring to the flowchart shown in fig. 3, fig. 3 is a timing diagram of a database synchronization between a storage device and the same terminal device. The terminal equipment sends a data acquisition request to the storage equipment for the first time on 1 day, the storage equipment sends the second class database file generated on 1 day to the terminal equipment, and the terminal equipment stores the received data of the second class database file on 1 day sent by the storage equipment to the database of the terminal equipment. The database in the storage device is updated on day 3, and the storage device generates a first type database file containing data change information of day 3 on day 3. And 4 days, the terminal equipment sends a data acquisition request to the storage equipment, and at the moment, the storage equipment judges that the data acquisition request is not sent for the first time, the first type database file generated in 3 days can be sent to the terminal equipment, and the terminal equipment can update the data of the database in the terminal equipment according to the first type database file generated in 3 days. Databases in the storage devices of 5 days and 6 days are updated, and the storage devices respectively generate the first-class database files of 5 days and 6 days. The terminal device sends a data acquisition request to the storage device for 7 days, and because the terminal device sends the data acquisition request for 4 days, the storage device can send two first class database files of 5 days and 6 days as first class target files to the terminal device at the moment, and the terminal device can update the data of the database in the terminal device by the first class target files.
If another terminal device different from the terminal device sends a data acquisition request for the same database to the storage device for the first time at 4 days, the storage device may send both the second type database file generated at 1 day and the first type database file generated at 3 days to the terminal device. When the terminal equipment receives the second class database file generated on 1 day and the first class database file generated on 3 days, each piece of data in the second class database file generated on 1 day can be covered on the database of the terminal equipment, and then the database of the terminal equipment is updated according to the first class database file generated on 3 days. In the subsequent process, if the storage device receives the data acquisition request sent by the terminal device again, the first type database file generated after 4 days can be sent to the terminal device on the basis of the database file sent on 4 days.
For different terminal devices, the storage device can distinguish each terminal device through the device identifier of the terminal device carried by the data acquisition request, and record the time of the data acquisition request sent by each terminal device each time.
As can be seen from the above examples, the present embodiment can make the database data in the terminal device consistent with the database data in the storage device, and avoid that the storage device sends the data of the entire database to the terminal device when the terminal device requests the data each time, so that the data traffic transmitted between the devices can be reduced, unnecessary traffic consumption is reduced, and the synchronization process of the database data is further accelerated. In addition, the method and the device do not need to determine the type of the database file to be acquired by the terminal equipment, so that the processing capacity of the terminal equipment can be reduced.
Fig. 4 is a schematic diagram of an interaction flow between a terminal device and a storage device according to an embodiment of the present application. The flows shown in fig. 4 are all directed to the same terminal device. The terminal device detects an operation of acquiring data by a user at a time point t1, and at this time, may send a data acquisition request to the storage device, where a category carried by the data acquisition request is a category 1 of the first type database file. When the storage device receives the data acquisition request, the first type target file can be determined from the stored first type database files, and the first type target file is sent to the terminal device. After receiving the first type object file, the terminal equipment updates the data in the first type object file into a database of the terminal equipment, and displays the data in the database to a user for the user to select the data to be acquired.
At time point t2, the terminal device detects again the operation that the user requests to acquire data. The terminal equipment detects that the terminal equipment does not perform database synchronization in the time between t1 and t2, and the interval time between t1 and t2 is longer than a preset duration threshold. At this time, the terminal device may send a data acquisition request of category 0 carrying the second-category database file to the storage device. When the storage device receives the data acquisition request, the second class object file can be determined from the second class database file, and the second class object file is sent to the terminal device. After receiving the second type object file, the terminal device can cover each piece of data in the second type object file into a database of the terminal device, and display the data in the database to a user for the user to select the data to be acquired.
In another embodiment of the present application, the storage device may generate the second type database file in a manner including steps 1 and 2 below:
step 1: and when the generation conditions of the preset second class database file are met, determining the retrieval conditions of all data of the database in the storage device.
In this embodiment, the generating conditions of the second class database file may include: the data change amount of the database in the storage device is larger than a preset change amount threshold; alternatively, the preset generation period arrives.
Wherein, since the database in the storage device can be updated continuously, after each update, the change operation to the database in the storage device can be recorded, for example, the change operation is recorded in the form of generating a log file. The storage device may use the number or amount of data of the log file as the amount of data change of the database.
When the storage device is started, the stored data and the data of the database can be synchronized, and if the stored data and the data have differences, the database is updated according to the stored data. And when the updating operation is finished, generating a second class database file.
In determining the search condition, the search condition may be determined according to the data type of the data stored in the database. For example, when images are stored in the database, the search condition is generally a time condition, and thus the pieces of data obtained by search are listed one by one in time sequence. Step 1 may specifically include: a start storage time and an end storage time for database data in the storage device are generated. The data between the start storage time and the end storage time is all the data of the database.
When video data is stored in the database, the retrieval condition may be a time condition or a name condition. The image and video data may be stored in the same database or in different databases.
The search conditions may be preset. The storage device may determine the retrieval conditions for all data of the database in the storage device from the stored retrieval condition information.
Step 2: and acquiring each piece of data from the database of the storage device according to the retrieval conditions, and generating a second class database file from each piece of data.
The storage device may convert each piece of data into a second type database file having a preset file format according to the preset file format. The format of the second class database file can be a temporary file format or a cache file format.
In a specific embodiment, in order to make the process of generating the file more controllable, the generated second type database file is more accurate, and the second type database file may be in a format of a cache file. Specifically, the storage device may store each piece of data read in a temporary file format in the process of reading each piece of data from the database of the storage device, and when the data in the database of the storage device is read, the generated temporary file may be converted into a cache file. In the conversion process, the suffix of the temporary file can be converted into the format of the cache file, the name of the cache file can be renamed, for example, the cache file can be named according to the modification time of the database.
During the process of reading data in the database of the storage device, faults such as power failure and the like which affect the reading of the database may occur. After the fault repair, if the temporary file exists in the device, it may be confirmed that the cache file is not generated. Therefore, in another embodiment, before step 1, it may be detected whether the above temporary file exists in the storage device, and if so, the temporary file is deleted, and the process returns to step 1. Therefore, the cache file generated each time can be ensured to be a file containing all data of the database in the storage device, so that the generated second-class database file is more accurate.
In order to increase the speed at which the storage device transmits database files, the second type of database file may be generated in a structured network data format. Therefore, after the second class object file is determined from the second class database file, the storage device can directly send the second class object file without converting the transmission format, and time can be saved.
In another embodiment of the present application, the storage device may generate the first type of database file in the following manner: data change information for a database in a storage device is determined, and a first type database file containing the data change information is generated.
The storage device may perform a change operation on the database in the storage device when receiving a database change request for the database in the storage device sent by the terminal device to the storage device, and determine data change information for the database in the storage device according to the change operation. The database change request may carry data to be changed, and the data to be changed may include at least one of data to be stored, data to be modified, and data to be deleted.
The data change information may include data representing an update operation of the database and update contents. For example, the data change information may include: database added data, deleted data, modified data, etc.
The storage device may generate a first type database file containing data modification information according to a preset file format. The format of the first type database file may be a log file format (log file format).
The storage device may detect a change operation of a specified unit in the storage device to the database, and generate a log file for each change operation, recording the respective log files. Therefore, all change operations aiming at the database can be recorded, omission is avoided, and consistency of database data in the terminal equipment and database data in the storage equipment is further ensured.
Fig. 5 is a flowchart of another database synchronization method according to an embodiment of the present application. The method is applied to the terminal equipment. The terminal equipment can be smart phones, computers, tablet computers, notebook computers and other equipment. The method of the present embodiment may be specifically performed by a client in a terminal device. The method of the present embodiment includes the following steps S501 to S503:
step S501: a data retrieval request is sent to a storage device for a database in the storage device.
The terminal device may send a data acquisition request for a database in the storage device to the storage device after detecting an input operation by the user. For example, the terminal device may transmit a data acquisition request for a database in the storage device to the storage device after detecting an operation of viewing a past image input by the user.
The data acquisition request may carry at least one of time information, account information, and the like.
Step S502: and receiving the first type target file sent by the storage equipment.
The first type of target files are as follows: the storage device determines a database file for the data acquisition request from among the stored respective database files of the first type. Each first type database file contains data change information of a database in the storage device corresponding to the generation time of the first type database file.
The first type of database file may be a log file. The first type database file may include data modification information for database data. The data change information may include data representing an update operation of the database and update contents. For example, the data change information may include: database added data, deleted data, modified data, etc.
In one embodiment, the target database file may be transmitted in a structured network data format.
Step S503: and updating the database in the terminal equipment according to the first type of target file.
Specifically, the step may perform processes such as adding, deleting or modifying on corresponding data of the database in the terminal device according to the data change information in the first type of object file, so that database data in the terminal device is consistent with database data in the storage device.
As can be seen from the foregoing, in this embodiment, the first type object file sent by the storage device and received by the terminal device is determined by the storage device from the stored first type database files. When a data acquisition request is received, the storage device does not need to obtain all data from the database by searching the database and send the data to the terminal device, but directly sends the stored first-type target file to the terminal device, so that the request of the terminal device can be responded more quickly, and the synchronization with the database data in the storage device is realized. Therefore, the method and the device can shorten the time consumption of the database synchronization process and improve the efficiency.
Meanwhile, the first type of target file contains data change information, so that the data volume of the file is small, and the sending time can be saved during sending. When the terminal equipment updates the database according to the first type of target file, the file contains data change information, so that only the changed data is required to be updated, and all data in the database are not required to be processed, thereby improving the updating speed.
After updating the database in the terminal device, the terminal device may also display each piece of data of the database in the terminal device for viewing by the user. When the terminal device displays each piece of data of the database, the terminal device can display the data according to the time information of each piece of data, and can also display the data according to the type of each piece of data.
For example, when each piece of data in the database is image data, for example, each piece of data includes: image identification, creation time of the image, storage path of the image, size of the image, resolution of the image, and the like. The terminal device can display each piece of data in the database in a time axis form for users to choose.
In another embodiment of the present application, in the embodiment shown in fig. 5, the terminal device may further receive the second type of object file sent by the storage device, and cover each piece of data in the second type of object file to the database in the terminal device.
The second type of object files are as follows: the storage device determines a database file for the data acquisition request from among the stored respective second-type database files. Each second class database file contains all the data of the database in the storage device when the second class database file is generated.
When each piece of data in the second class object file is covered on the database in the terminal equipment, the method specifically may include: when the data exists in the database of the terminal equipment, deleting the data existing in the database of the terminal equipment, and storing each piece of data in the second type of target file into the database of the terminal equipment; when there is no data in the database of the terminal device, that is, when the database is an empty database, each piece of data in the second type object file may be directly stored in the database of the terminal device.
The second class database file may be a temporary file or a cache file. The terminal device may parse all the data in the database of the storage device from the second class database file according to the format of the second class database file, and cover the parsed data in the database of the terminal device.
In another embodiment of the present application, when sending a data acquisition request to a storage device, it may further:
information representing the category of the database file to be acquired is determined, and the determined information is transmitted to the storage device.
The terminal device may send the information carried in the data acquisition request to the storage device, and the storage device may obtain the information from the data acquisition request. The method can reduce the number of data transmission times between the devices and improve the data processing efficiency. When the terminal equipment needs to synchronize the database, the terminal equipment can actively send the types of the needed database files to the storage equipment. In this way, the storage device can reduce the amount of data stored without having to record which database files the terminal device has acquired.
The terminal device may also directly send the information to the storage device, and the storage device may directly receive the information. The terminal device may transmit the information before or after transmitting the above-mentioned data acquisition request, which is not particularly limited in this application.
The terminal device may determine the category of the database file to be acquired in the following manner:
when the data acquisition request is a data acquisition request which is sent to the storage device by the terminal device for the first time, determining the category to be acquired as the category of the second-type database file; and when the data acquisition request is not the data acquisition request which is sent to the storage device for the first time by the terminal device, determining the category as the category of the first-type database file.
Or when the database is not established in the terminal equipment, determining the category as the category of the second class database file; when a database is established in the terminal device, the above category is determined as the category of the first category database file. When the terminal device performs an operation of storing each piece of data in the second class database file into the database of the terminal device, the database is considered to be established in the terminal device.
Or when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; and when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than a preset time length threshold, determining the category as the category of the first-type database file. The preset duration threshold may be a preset value, for example, may be a value such as 3 days, one week, or one month.
When the terminal device determines that the category is the category of the first-type database file, the terminal device can also acquire time information of the database file acquired from the storage device last time, and send the time information to the storage device. When in transmission, the terminal equipment can add the time information into a data acquisition request, and the time information is transmitted to the storage equipment through the data acquisition request, so that the frequency of transmitting data can be reduced, and the processing efficiency is improved. The time information may be a point in time. The last time the time information of the database file was obtained from the storage device, it is understood that the time information of the database file is obtained from the storage device before the current time and closest to the current time. The time information may be the time of last receiving the database file sent by the storage device, or may be the time of last generating the database file sent by the storage device.
In this embodiment, when the terminal device needs to synchronize the database, the terminal device may actively send the type of the required database file to the storage device. In this way, the storage device can reduce the amount of data stored without having to record which database files the terminal device has acquired.
When the terminal equipment updates the database data and displays the database data, the data identifier to be checked can be determined from the displayed data, and a downloading request carrying the data identifier to be checked and a storage path of the data to be checked is sent to the storage equipment. When receiving the downloading request, the storage device determines the data to be checked according to the data identifier to be checked and the storage path of the data to be checked, and sends the data to be checked to the terminal device. The terminal equipment can receive the data to be checked sent by the storage equipment and display the data to be checked.
Fig. 6 is a schematic structural diagram of a database synchronization device according to an embodiment of the present application. The embodiment of the device is applied to a storage device, and the storage device can be a server or can be other computers capable of storing data besides the server. The server may be a cloud server. This embodiment of the device corresponds to the embodiment of the method shown in fig. 1. The device comprises the following modules:
A first receiving module 601, configured to receive a data acquisition request sent by a terminal device and directed to a database in a storage device;
a first determining module 602, configured to determine a first type object file for the data acquisition request from the stored first type database files; each first-type database file contains data change information of a database in storage equipment corresponding to the generation time of the first-type database file;
and the first sending module 603 is configured to send the first target file to the terminal device, so that the terminal device updates the database in the terminal device according to the first type of target file.
In another embodiment of the present application, in the embodiment shown in fig. 6, the storage device is further configured to store respective second-type database files, where each second-type database file includes all data of the database in the storage device when the second-type database file is generated. The first receiving module 601 is further configured to:
and receiving information which is sent by the terminal equipment and indicates the category of the database file to be acquired.
The first determining module 602 is specifically configured to:
when the category is the category of the first-class database file, determining a first-class target file aiming at the data acquisition request from the stored first-class database files;
The first determining module 602 is further configured to:
when the category is the category of the second-class database file, determining a second-class target file aiming at the data acquisition request from the stored second-class database files; or alternatively, the process may be performed,
the first sending module 603 is further configured to:
and sending the second type of target file to the terminal equipment so that the terminal equipment covers all pieces of data in the second type of target file in a database in the terminal equipment.
In another embodiment of the present application, in the embodiment shown in fig. 6, the first determining module 602 is specifically configured to:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
In another embodiment of the present application, in the embodiment shown in fig. 6, the first receiving module 601 is further configured to:
receiving time information sent by a terminal device and representing that a database file is acquired from a storage device last time;
the first determining module 602 is specifically configured to:
determining a first type target file for the data acquisition request from the stored first type database files according to the time information; or alternatively, the process may be performed,
determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: the storage device receives the time of the data acquisition request sent by the terminal device.
In another embodiment of the present application, in the embodiment shown in fig. 6, the apparatus further includes:
a first generation module (not shown in the figure) configured to determine a search condition for all data of the database in the storage device when a preset generation condition of the second type database file is satisfied, acquire each piece of data from the database of the storage device according to the search condition, and generate each piece of data into the second type database file.
In another embodiment of the present application, in the embodiment shown in fig. 6, the generating conditions of the second class database file include:
the data change amount of the database in the storage device is larger than a preset change amount threshold; alternatively, the preset generation period arrives.
In another embodiment of the present application, in the embodiment shown in fig. 6, the apparatus further includes:
a second generation module (not shown in the figure) is configured to determine data change information for the database in the storage device, and generate a first type database file containing the data change information.
Since the above embodiment of the apparatus is obtained based on the embodiment of the method shown in fig. 1, and has the same technical effects as the method, the technical effects of the embodiment of the apparatus are not described herein again. For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
Fig. 7 is a schematic structural diagram of another database synchronization device according to an embodiment of the present application. The embodiment of the device is applied to terminal equipment, and the terminal equipment can be smart phones, computers, tablet computers, notebook computers and other equipment. This embodiment of the device corresponds to the embodiment of the method shown in fig. 5. The device comprises:
a second sending module 701, configured to send a data acquisition request for a database in a storage device to the storage device;
a second receiving module 702, configured to receive a first type of object file sent by a storage device; the target database file is as follows: the storage device determines database files aiming at the data acquisition request from the stored database files of the first type; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and the updating module 703 is configured to update the database in the terminal device according to the first type of object file.
In another embodiment of the present application, in the embodiment shown in fig. 7, the apparatus further includes: a cover module (not shown).
The second receiving module 702 is further configured to receive a second type of object file sent by the storage device; the second type of object files are as follows: the storage device determines database files aiming at the data acquisition request from the stored second class database files, and each second class database file contains all data of a database in the storage device when the second class database file is generated;
And the coverage module is used for covering all pieces of data in the second class of object files to a database in the terminal equipment.
In another embodiment of the present application, in the embodiment shown in fig. 7, the apparatus may further include: a second determining module (not shown in the figure) for determining information representing the category of the database file to be acquired.
The second sending module 701 is further configured to send the determined information to the storage device.
The second determining module is specifically configured to:
when the data acquisition request is a data acquisition request which is sent to the storage device for the first time by the terminal device, determining the category as the category of the second category database file; when the data acquisition request is not a data acquisition request which is sent to the storage device for the first time by the terminal device, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when the database is not established in the terminal equipment, determining the category as the category of the second class database file; when a database is established in the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second category database file; when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than a preset time length threshold, determining the category as the category of the first-type database file;
The apparatus may further include:
and an acquisition module (not shown in the figure) for acquiring the time information of the database file acquired from the storage device last time and transmitting the time information to the storage device when the category is determined to be the category of the first-type database file.
In another embodiment of the present application, in the embodiment shown in fig. 7, the apparatus further includes:
a display module (not shown in the figure) for displaying each piece of data of the database in the terminal device after updating the database in the terminal device.
Since the above embodiment of the apparatus is obtained based on the embodiment of the method shown in fig. 5, the same technical effects as those of the method are achieved, and therefore the technical effects of the embodiment of the apparatus are not described herein. For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
Fig. 8 is a schematic structural diagram of a database synchronization system according to an embodiment of the present application. The system comprises: a storage device 801 and a terminal device 802. The storage device 801 may be a server or a computer that can store data other than the server. The server may be a cloud server. The terminal device 802 may be a smart phone, a computer, a tablet computer, a notebook computer, or the like.
A terminal device 802 for transmitting a data acquisition request for a database in the storage device 801 to the storage device 801;
a storage device 801, configured to receive a data acquisition request sent by a terminal device 802 for a database in the storage device 801, determine a first type object file for the data acquisition request from stored first type database files, and send the first type object file to the terminal device 802; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
the terminal device 802 is configured to receive the first type of object file sent by the storage device 801, and update the database in the terminal device 802 according to the first type of object file.
In the present embodiment, the terminal device 802 may transmit a data acquisition request for a database in the storage device 801 to the storage device 801 after detecting an input operation by the user.
The data acquisition request may carry at least one of time information, account information, and the like.
The storage device 801 may be configured to store one or more databases and a correspondence between each database and account information. When the storage device 801 receives the data acquisition request sent by the terminal device 802, a database corresponding to the account information may be determined according to the account information carried by the data acquisition request and the corresponding relationship between each stored database and the account information, where the database is the database corresponding to the data acquisition request, that is, the database where the terminal device 802 wants to acquire data.
When determining the first type object file from the stored first type database files, the storage device 801 may determine the first type object file from the first type database files according to the generation time of the first type database files and the time information carried in the data acquisition request.
The storage device 801 sends the first type of object file to the terminal device 802, and the terminal device 802 may receive the first type of object file sent by the storage device 801 and update the database in the terminal device 802 according to the first type of object file, so as to achieve data synchronization between the database in the terminal device 802 and the database in the storage device 801.
In sending the first type object file, the storage device 801 may convert the first type object file into a structured network data format, and send the first type object file to the terminal device 802 in the form of the network data format.
The structured network data format may include characters of a protocol header, a protocol trailer, etc. of a network transport protocol (e.g., http). The first type of object file is converted into a structured network data format, and a protocol header character, a protocol tail character and the like can be added into the first type of object file. Thus, after the first type target file is determined, the first type target file can be transmitted.
As can be seen from the foregoing, in this embodiment, the storage device may determine the first type object file from the stored first type database files when receiving the data acquisition request sent by the terminal device, send the first type object file to the terminal device, and update the database in the terminal device according to the first type object file by the terminal device. Because each first-class database file contains the data change information of the database in the storage device, when a data acquisition request is received, the storage device does not need to obtain data from the database in a database searching mode and send the data to the terminal device, but can directly send the stored first-class database file to the terminal device so as to realize the synchronization of the database to the terminal device, so that the time consumption of a database synchronization process can be shortened, and the efficiency is improved.
If the first type database file is not already generated when the storage device 801 receives the data acquisition request sent by the terminal device 802, the data in the storage device database may be directly retrieved, and the retrieved data is sent to the terminal device, so as to respond to each data acquisition request of the terminal device as much as possible.
In another embodiment of the present application, in the embodiment shown in fig. 8, the storage device is further configured to store respective second-type database files, where each second-type database file includes all data of the database in the storage device when the second-type database file is generated.
The terminal device may determine information indicating a category of the database file to be acquired when the storage device transmits the data acquisition request, and transmit the determined information to the storage device. The storage device receives information which is sent by the terminal device and indicates the category of the database file to be acquired.
The categories of the first type of database file and the categories of the second type of database file may be represented by numbers or letters. The terminal device may send the information carried in a data acquisition request to the storage device, from which the storage device may obtain the information. The method can reduce the number of data transmission times between the devices and improve the data processing efficiency. When the terminal equipment needs to synchronize the database, the terminal equipment can actively send the types of the needed database files to the storage equipment. In this way, the storage device can reduce the amount of data stored without having to record which database files the terminal device has acquired.
The terminal device may also directly send the information to the storage device, and the storage device may directly receive the information. The terminal device may transmit the information before or after transmitting the above-mentioned data acquisition request, which is not particularly limited in this application.
The terminal device may determine the category of the database to be acquired in a number of ways. For example, when the data acquisition request is a data acquisition request that is first sent by the terminal device to the storage device, determining the category as a category of the second-type database file; and when the data acquisition request is not the data acquisition request which is sent to the storage device for the first time by the terminal device, determining the category as the category of the first-type database file.
Or when the database is not established in the terminal equipment, determining the category as the category of the second class database file; when a database is established in the terminal device, the above category is determined as the category of the first category database file. And when the terminal equipment performs the operation of storing all pieces of data in the second class database file into the database of the terminal equipment, the database is considered to be established in the terminal equipment.
Or when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; and when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than a preset time length threshold, determining the category as the category of the first-type database file. The preset duration threshold may be a preset value, for example, may be a value such as 3 days, one week, or one month.
When the terminal device determines that the category is the category of the first-type database file, the terminal device can also acquire time information of the database file acquired from the storage device last time, and send the time information to the storage device. When in transmission, the terminal equipment can add the time information into a data acquisition request, and the time information is transmitted to the storage equipment through the data acquisition request, so that the frequency of transmitting data can be reduced, and the processing efficiency is improved. The time information may be a point in time. The last time the time information of the database file was obtained from the storage device, it is understood that the time information of the database file is obtained from the storage device before the current time and closest to the current time. The time information may be the time of last receiving the database file sent by the storage device, or may be the time of last generating the database file sent by the storage device.
In this embodiment, when the category is a category of the first-type database file, the storage device may determine a first-type target file for the data acquisition request from the stored first-type database files. When the category is a category of the second-class database file, the storage device may further determine a second-class target file for the data acquisition request from the stored respective second-class database files.
In this embodiment, when determining the first type of object file, the storage device may further receive time information of the last database file obtained from the storage device sent by the terminal device, and determine, according to the time information, the first type of object file for the data obtaining request from the stored first type of database files.
Specifically, when the terminal device sends the time information through the data acquisition request, the storage device may parse the data acquisition request to obtain the time information.
When the storage device determines the first type target file for the data acquisition request from the stored first type database files according to the time information, the first type database file with the generation time later than the time information can be determined as the first type target file for the data acquisition request. The first type database file whose generation time is between the time information and the current time may be determined as the first type target file for the data acquisition request. The current time is the time when the storage device receives the data acquisition request sent by the terminal device. In this embodiment, there may be a plurality of first type database files whose time is later than the time information, or the first type database files whose time is between the time information and the current time are generated, and in this case, all of the plurality of first type database files may be used as the first type target files.
The determining, by the storage device, the second class object file for the data acquisition request from the stored second class database files may specifically include: and determining the second type database file with the latest generation time as a second type target file for the data acquisition request. The data in the second class database file with the latest generation time is up to date, and the data of the terminal equipment database can be up to date by determining the second class target file in the mode, and the consistency with the data of the database in the storage device is maintained.
When the storage device sends the second class object files to the terminal device, each second class database file may be generated according to the structured network data format. In this way, when the second type object file is transmitted, the transmission format does not need to be converted, and time can be saved.
According to the method and the device, the first type target file can be determined from the first type database file according to the type sent by the terminal device, or the second type target file can be determined from the second type database file, so that database data in the terminal device are consistent with database data in the storage device, the storage device is prevented from sending the data of the whole database to the terminal device when the terminal device requests the data each time, therefore, the data flow transmitted between the devices can be reduced, unnecessary flow consumption is reduced, and the synchronization process of the database data is further accelerated.
Meanwhile, the storage device can determine the first type of target file or the second type of target file according to the type sent by the terminal device, and the storage device does not need to record the information such as the times and time of sending the data acquisition request by the terminal device and the device identification of the terminal device or determine the first type of target file or the second type of target file according to the information, so that the stored data volume can be reduced, and the processing flow of the storage device is simplified.
The terminal equipment can also receive the second type of target file sent by the storage equipment, and all pieces of data in the second type of target file are covered on a database in the terminal equipment. The terminal device may specifically be configured to: when the data exists in the database of the terminal equipment, deleting the data existing in the database of the terminal equipment, and storing each piece of data in the second type of target file into the database of the terminal equipment; when there is no data in the database of the terminal device, that is, when the database is an empty database, each piece of data in the second type object file may be directly stored in the database of the terminal device.
When the terminal equipment updates the database data and displays the database data, the data identifier to be checked can be determined from the displayed data, and a downloading request carrying the data identifier to be checked and a storage path of the data to be checked is sent to the storage equipment. When receiving the downloading request, the storage device determines the data to be checked according to the data identifier to be checked and the storage path of the data to be checked, and sends the data to be checked to the terminal device. The terminal equipment can receive the data to be checked sent by the storage equipment and display the data to be checked.
In another embodiment of the present application, when the terminal device does not send information indicating the category of the database file to be acquired to the storage device, the storage device may specifically be configured to:
judging whether the data acquisition request is a data acquisition request which is sent to the storage device for the first time by the terminal device, if not, determining a first type target file aiming at the data acquisition request from all stored first type database files.
The storage device may determine, according to the stored record information of the data acquisition request of the terminal device, whether the data acquisition request is a data acquisition request sent by the terminal device to the storage device for the first time. The record information of the data acquisition request may include a time of each data acquisition request, where the time may be a receiving time of the data acquisition request received by the storage device, or may be a sending time of the data acquisition request sent by the terminal device carried by the data acquisition request to the storage device.
When the above judgment result is no, the database in the terminal device may be considered to contain all or part of the data of the database in the storage device, that is, the terminal device and the database of the storage device are synchronized. In this case, the first type object file may be determined from the first type database file.
When the judgment result is yes, the database in the terminal equipment can be considered to not contain the data of the database in the storage equipment, namely the terminal equipment is not synchronized with the database of the storage equipment, and the terminal equipment does not establish the database yet. In this case, the storage device may also be used to:
a second type object file for the data acquisition request is determined from the stored respective second type database files.
In this embodiment, the terminal device does not need to send the type of the database file to be acquired to the storage device, and the storage device determines which type of database file to send to the terminal device according to the recorded information. This way the throughput of the terminal device can be reduced.
In another embodiment of the present application, when the storage device determines the first type of target file for the data acquisition request from the stored first type of database files, the storage device may specifically:
determining a first time when the terminal equipment sends a data acquisition request to the storage equipment last time, and determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request.
The storage device may record the time at which the terminal device sent the data acquisition request each time. The data acquisition request last sent to the storage device is a data acquisition request satisfying the following conditions: the time of the data acquisition request sent by the terminal equipment is closest to the time of the data acquisition request sent by the terminal equipment and is earlier than the time of the data acquisition request sent by the terminal equipment.
The current time is the time when the storage device receives the data acquisition request sent by the terminal device, that is, the time when the storage device receives the data acquisition request sent by the terminal device.
When a plurality of first type database files exist between the first time and the current time, the plurality of first type database files can be used as first type target files.
According to the method and the device for determining the first type object files, the first type object files can be determined from the first type database files under the condition that the terminal device does not send time information to the storage device, and processing accuracy can be improved.
In another embodiment of the present application, in the embodiment shown in fig. 8, the storage device 801 is further configured to generate a second type of database file by:
when the generation conditions of the preset second class database file are met, determining the retrieval conditions of all data of the database in the storage device, acquiring each piece of data from the database of the storage device according to the retrieval conditions, and generating the second class database file by each piece of data.
In this embodiment, the generating conditions of the second class database file may include: the data change amount of the database in the storage device is larger than a preset change amount threshold; alternatively, the preset generation period arrives.
Wherein, since the database in the storage device can be updated continuously, after each update, the change operation to the database in the storage device can be recorded, for example, the change operation is recorded in the form of generating a log file. The storage device may use the number or amount of data of the log file as the amount of data change of the database.
When the storage device is started, the stored data and the data of the database can be synchronized, and if the stored data and the data have differences, the database is updated according to the stored data. And when the updating operation is finished, generating a second class database file.
The storage device may generate a start storage time and a stop storage time for database data in the storage device as the above-described retrieval conditions. The data between the start storage time and the end storage time is all the data of the database.
The storage device may convert each piece of data into a second type database file having a preset file format according to the preset file format. The format of the second class database file can be a temporary file format or a cache file format.
In a specific embodiment, in order to make the process of generating the file more controllable, the generated second type database file is more accurate, and the second type database file may be in a format of a cache file. Specifically, the storage device may store each piece of data read in a temporary file format in the process of reading each piece of data from the database of the storage device, and when the data in the database of the storage device is read, the generated temporary file may be converted into a cache file. In the conversion process, the suffix of the temporary file can be converted into the format of the cache file, the name of the cache file can be renamed, for example, the cache file can be named according to the modification time of the database.
During the process of reading data in the database of the storage device, faults such as power failure and the like which affect the reading of the database may occur. After the failover, if the temporary file exists in the storage device, it may be confirmed that the cache file is not generated. Thus, in another embodiment, the storage device may detect whether the above-described temporary file exists in the storage device before determining the retrieval conditions for all data of the database in the storage device, and if so, delete the temporary file. Therefore, the cache file generated each time can be ensured to be a file containing all data of the database in the storage device, so that the generated second-class database file is more accurate.
In order to increase the speed at which the storage device transmits database files, the second type of database file may be generated in a structured network data format. Therefore, after the second class object files are determined from the second class database files, the storage device can directly send the second class object files without converting the transmission format, and time can be saved.
In another embodiment of the present application, in the embodiment shown in fig. 8, the storage device 801 is further configured to generate a first type of database file by: data change information for the database in the storage device 801 is determined, and a first type database file containing the data change information is generated.
The storage device may perform a change operation on the database in the storage device when receiving a database change request for the database in the storage device sent by the terminal device to the storage device, and determine data change information for the database in the storage device according to the change operation. The database change request may carry data to be changed, and the data to be changed may include at least one of data to be stored, data to be modified, and data to be deleted.
The data change information may include data representing an update operation of the database and update contents. For example, the data change information may include: database added data, deleted data, modified data, etc.
The storage device may generate a first type database file containing data modification information according to a preset file format. The format of the first type database file may be a log file format (log file format).
The storage device may detect a change operation of a specified unit in the storage device to the database, and generate a log file for each change operation, recording the respective log files. Therefore, all change operations aiming at the database can be recorded, omission is avoided, and consistency of database data in the terminal equipment and database data in the storage equipment is further ensured.
Fig. 9 is a schematic structural diagram of a memory device according to an embodiment of the present application. The storage device comprises a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902 and the memory 903 are in communication with each other through the communication bus 904;
a memory 903 for storing a computer program;
the processor 901 is configured to implement the database synchronization method provided in the embodiment of the present application when executing the program stored in the memory 903. The method comprises the following steps:
receiving a data acquisition request aiming at a database in the storage device, which is sent by a terminal device;
Determining a first type object file aiming at the data acquisition request from the stored first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In this embodiment, the storage device may determine a first type object file from the stored first type database files when receiving the data acquisition request sent by the terminal device, send the first type object file to the terminal device, and the terminal device updates the database in the terminal device according to the first type object file. Because each first-class database file contains the data change information of the database in the storage device, when a data acquisition request is received, the storage device does not need to obtain data from the database in a database searching mode and send the data to the terminal device, but can directly send the stored first-class database file to the terminal device so as to realize the synchronization of the database to the terminal device, so that the time consumption of a database synchronization process can be shortened, and the efficiency is improved.
Fig. 10 is a schematic structural diagram of a terminal device according to an embodiment of the present application. The terminal device comprises a processor 1001, a communication interface 1002, a memory 1003 and a communication bus 1004, wherein the processor 1001, the communication interface 1002 and the memory 1003 complete communication with each other through the communication bus 1004;
a memory 1003 for storing a computer program;
the processor 1001 is configured to implement the database synchronization method provided in the embodiment of the present application when executing the program stored in the memory 1003. The method comprises the following steps:
transmitting a data acquisition request for a database in the storage device to the storage device;
receiving a first type target file sent by a storage device; the first type of target files are as follows: the storage device determines a database file for the data acquisition request from among the stored respective database files of the first type. Each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and updating the database in the terminal equipment according to the first type of target file.
In this embodiment, the first type object file sent by the storage device and received by the terminal device is determined by the storage device from the stored first type database files. When a data acquisition request is received, the storage device does not need to obtain all data from the database by searching the database and send the data to the terminal device, but directly sends the stored first-type target file to the terminal device, so that the request of the terminal device can be responded more quickly, and the synchronization with the database data in the storage device is realized. Therefore, the method and the device can shorten the time consumption of the database synchronization process and improve the efficiency.
The embodiment of the application provides a computer readable storage medium, and a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the database synchronization method provided by the embodiment of the application is realized. The method comprises the following steps:
receiving a data acquisition request aiming at a database in the storage device, which is sent by a terminal device;
determining a first type object file aiming at the data acquisition request from the stored first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and sending the first type target file to the terminal equipment so that the terminal equipment updates a database in the terminal equipment according to the first type target file.
In this embodiment, the storage device may determine a first type object file from the stored first type database files when receiving the data acquisition request sent by the terminal device, send the first type object file to the terminal device, and the terminal device updates the database in the terminal device according to the first type object file. Because each first-class database file contains the data change information of the database in the storage device, when a data acquisition request is received, the storage device does not need to obtain data from the database in a database searching mode and send the data to the terminal device, but can directly send the stored first-class database file to the terminal device so as to realize the synchronization of the database to the terminal device, so that the time consumption of a database synchronization process can be shortened, and the efficiency is improved.
The embodiment of the application provides a computer readable storage medium, and a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the database synchronization method provided by the embodiment of the application is realized. The method comprises the following steps:
transmitting a data acquisition request for a database in the storage device to the storage device;
receiving a first type target file sent by a storage device; the first type of target files are as follows: the storage device determines a database file for the data acquisition request from among the stored respective database files of the first type. Each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
and updating the database in the terminal equipment according to the first type of target file.
In this embodiment, the first type object file sent by the storage device and received by the terminal device is determined by the storage device from the stored first type database files. When a data acquisition request is received, the storage device does not need to obtain all data from the database by searching the database and send the data to the terminal device, but directly sends the stored first-type target file to the terminal device, so that the request of the terminal device can be responded more quickly, and the synchronization with the database data in the storage device is realized. Therefore, the method and the device can shorten the time consumption of the database synchronization process and improve the efficiency.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, with reference to the description of method embodiments in part.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the present application. Any modifications, equivalent substitutions, improvements, etc. that are within the spirit and principles of the present application are intended to be included within the scope of the present application.

Claims (25)

1. A database synchronization method, applied to a storage device, the method comprising:
receiving a data acquisition request aiming at a database in the storage device, which is sent by a terminal device;
receiving information which is sent by the terminal equipment and indicates the category of the database file to be acquired;
when the category is the category of the first-class database file, determining a first-class target file aiming at the data acquisition request from the stored first-class database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
the first type target file is sent to the terminal equipment, so that the terminal equipment updates a database in the terminal equipment according to the first type target file;
when the category is the category of the second-class database file, determining a second-class target file aiming at the data acquisition request from the stored second-class database files; wherein each second class database file contains all data of the database in the storage device when the second class database file is generated;
And sending the second type object file to the terminal equipment so that the terminal equipment covers all pieces of data in the second type object file to a database in the terminal equipment.
2. The method of claim 1, wherein the step of determining a second type of object file for the data acquisition request from the stored respective second type of database file comprises:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
3. The method of claim 1, wherein the step of determining a first type of object file for the data acquisition request from the stored respective first type of database file comprises:
receiving time information of a database file acquired from the storage device last time, which is sent by the terminal device, and determining a first type target file aiming at the data acquisition request from all stored first type database files according to the time information; or alternatively, the process may be performed,
determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: and the storage device receives the time of the data acquisition request sent by the terminal device.
4. The method of claim 1, wherein the second class database file is generated by:
when the generation conditions of the preset second class database file are met, determining the retrieval conditions of all data of the database in the storage equipment;
and according to the retrieval conditions, acquiring each piece of data from the database of the storage equipment, and generating a second class database file from each piece of data.
5. The method of claim 4, wherein the generating conditions of the second class database file comprise:
the data change amount of the database in the storage device is larger than a preset change amount threshold; or alternatively, the process may be performed,
the preset generation period arrives.
6. The method of claim 1, wherein the first type database file is generated by:
determining data change information for a database in the storage device;
and generating a first type database file containing the data change information.
7. A database synchronization method, applied to a terminal device, the method comprising:
sending a data acquisition request aiming at a database in a storage device to the storage device;
Determining information representing the category of the database file to be acquired, and sending the determined information to the storage device, wherein the category is the category of the first type database file or the category of the second type database file;
receiving a first type target file sent by the storage equipment; the first type of target files are as follows: when the category is the category of the first-type database file, the storage device determines a database file aiming at the data acquisition request from the stored first-type database files; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
updating a database in the terminal equipment according to the first type of target file;
receiving a second type object file sent by the storage equipment; wherein the second class of object files are: when the category is the category of the second-class database file, the storage device determines a second-class target file aiming at the data acquisition request from the stored second-class database files; wherein each second class database file contains all data of the database in the storage device when the second class database file is generated;
And covering each piece of data in the second type of target file to a database in the terminal equipment.
8. The method as recited in claim 7, further comprising:
determining information representing the category of the database file to be acquired, and transmitting the determined information to the storage device;
the method further comprises the steps of: the category is determined in the following way:
when the data acquisition request is a data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the second category database file; when the data acquisition request is not the data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when a database is not established in the terminal equipment, determining the category as the category of the second-class database file; when a database is established in the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than the preset time length threshold, determining the category as the category of the first-type database file;
When determining that the category is a category of the first category database file, the method further includes:
and acquiring time information of the database file acquired from the storage device last time, and sending the time information to the storage device.
9. The method according to claim 7, wherein after updating the database in the terminal device, the method further comprises:
and displaying each piece of data of the database in the terminal equipment.
10. A database synchronization apparatus for use with a storage device, the apparatus comprising:
the first receiving module is used for receiving a data acquisition request aiming at a database in the storage device and sent by the terminal device, and information representing the category of a database file to be acquired;
the first determining module is used for determining a first type target file aiming at the data acquisition request from all stored first type database files when the type is the type of the first type database files; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
The first sending module is used for sending the first type target file to the terminal equipment so that the terminal equipment can update a database in the terminal equipment according to the first type target file;
the first determining module is further configured to determine, when the category is a category of the second-class database file, a second-class target file for the data acquisition request from the stored second-class database files; wherein each second class database file contains all data of the database in the storage device when the second class database file is generated;
the first sending module is further configured to send the second type object file to the terminal device, so that the terminal device covers each piece of data in the second type object file to a database in the terminal device.
11. The apparatus according to claim 10, wherein the first determining module is specifically configured to:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
12. The apparatus of claim 10, wherein the first receiving module is further configured to:
Receiving time information sent by the terminal equipment and representing that a database file is acquired from the storage equipment last time;
the first determining module is specifically configured to:
determining a first type target file aiming at the data acquisition request from the stored first type database files according to the time information; or alternatively, the process may be performed,
the first determining module is specifically configured to:
determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: and the storage device receives the time of the data acquisition request sent by the terminal device.
13. The apparatus of claim 10, wherein the apparatus further comprises:
the first generation module is used for determining the retrieval conditions of all data of the database in the storage device when the generation conditions of the preset second class database file are met, acquiring all data from the database of the storage device according to the retrieval conditions, and generating the second class database file by all data.
14. The apparatus of claim 13, wherein the second class database file generation conditions comprise:
the data change amount of the database in the storage device is larger than a preset change amount threshold; or alternatively, the process may be performed,
the preset generation period arrives.
15. The apparatus of claim 10, wherein the apparatus further comprises:
and the second generation module is used for determining data change information aiming at the database in the storage device and generating a first-class database file containing the data change information.
16. A database synchronization apparatus, for application to a terminal device, the apparatus comprising:
the second sending module is used for sending a data acquisition request aiming at a database in the storage device to the storage device;
the second determining module is used for determining information representing the category of the database file to be acquired and sending the determined information to the storage device, wherein the category is the category of the first type database file or the category of the second type database file;
the second receiving module is used for receiving the first type target files sent by the storage equipment; wherein, the target database file is: when the category is the category of the first-type database file, the storage device determines a database file aiming at the data acquisition request from the stored first-type database files; each first-type database file contains data change information of a database in the storage device corresponding to the generation time of the first-type database file;
The updating module is used for updating the database in the terminal equipment according to the first type of target file;
the second receiving module is also used for receiving a second class object file sent by the storage equipment; wherein the second class of object files are: when the category is the category of the second-class database file, the storage device determines a second-class target file aiming at the data acquisition request from the stored second-class database files; wherein each second class database file contains all data of the database in the storage device when the second class database file is generated;
and the coverage module is used for covering all the pieces of data in the second class object file to a database in the terminal equipment.
17. The apparatus of claim 16, wherein the apparatus further comprises:
the second determining module is used for determining information representing the category of the database file to be acquired;
the second sending module is further configured to send the determined information to the storage device;
the second determining module is specifically configured to:
when the data acquisition request is a data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the second category database file; when the data acquisition request is not the data acquisition request which is sent to the storage equipment for the first time by the terminal equipment, determining the category as the category of the first-type database file; or alternatively, the process may be performed,
When a database is not established in the terminal equipment, determining the category as the category of the second-class database file; when a database is established in the terminal equipment, determining the category as the category of the second category database file; or alternatively, the process may be performed,
when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is greater than a preset time length threshold, determining the category as the category of the second-class database file; when the database is established in the terminal equipment and the non-updated time length of the database in the terminal equipment is not more than the preset time length threshold, determining the category as the category of the first-type database file;
the apparatus further comprises:
the acquisition module is used for acquiring time information of the database file acquired from the storage device last time when the category is determined to be the category of the first-type database file;
the second sending module is further configured to send the time information to the storage device.
18. The apparatus of claim 16, wherein the apparatus further comprises:
and the display module is used for displaying each piece of data of the database in the terminal equipment after updating the database in the terminal equipment.
19. A database synchronization system, comprising: a storage device and a terminal device;
the terminal equipment is used for sending a data acquisition request aiming at a database in the storage equipment to the storage equipment;
the storage device is used for receiving a data acquisition request aiming at a database in the storage device, which is sent by the terminal device, determining a first type target file aiming at the data acquisition request from stored first type database files, and sending the first type target file to the terminal device; each first-type database file comprises data change information of a database in the storage device corresponding to the generation time of the first-type database file;
the terminal equipment is used for receiving the first type of target files sent by the storage equipment and updating a database in the terminal equipment according to the first type of target files;
the storage device is further used for storing each second class database file; each second class database file contains all data of the database in the storage device when the second class database file is generated;
the storage device is further used for;
Receiving information which is sent by the terminal equipment and indicates the category of the database file to be acquired;
the storage device is specifically configured to:
when the category is the category of the first-class database file, determining a first-class target file aiming at the data acquisition request from the stored first-class database files;
the storage device is further configured to:
when the category is the category of the second class database file, determining a second class target file aiming at the data acquisition request from the stored second class database files, and sending the second class target file to the terminal equipment;
the terminal device is specifically configured to:
and receiving a second type of target file sent by the storage device, and covering each piece of data in the second type of target file to a database in the terminal device.
20. The system according to claim 19, characterized in that said storage device is specifically configured to:
and determining the second type database file with the latest generation time as a second type target file for the data acquisition request.
21. The system of claim 19, wherein the storage device is further configured to:
Receiving time information of the database file acquired from the storage device last time, which is sent by the terminal device;
the storage device is specifically configured to:
determining a first type target file aiming at the data acquisition request from all stored second type database files according to the time information; or alternatively, the process may be performed,
the storage device is specifically configured to:
determining a first time when the terminal equipment transmits a data acquisition request to the storage equipment last time; determining a first type database file with the generation time between the first time and the current time from the stored first type database files as a first type target file for the data acquisition request; wherein, the current time is: and the terminal equipment sends the time of the data acquisition request to the storage equipment.
22. The storage device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-6 when executing a program stored on a memory.
23. The terminal equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 7-9 when executing a program stored on a memory.
24. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-6.
25. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 7-9.
CN201810380155.0A 2018-04-25 2018-04-25 Database synchronization method, device and system Active CN110413684B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810380155.0A CN110413684B (en) 2018-04-25 2018-04-25 Database synchronization method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810380155.0A CN110413684B (en) 2018-04-25 2018-04-25 Database synchronization method, device and system

Publications (2)

Publication Number Publication Date
CN110413684A CN110413684A (en) 2019-11-05
CN110413684B true CN110413684B (en) 2023-05-02

Family

ID=68345482

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810380155.0A Active CN110413684B (en) 2018-04-25 2018-04-25 Database synchronization method, device and system

Country Status (1)

Country Link
CN (1) CN110413684B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111259178A (en) * 2020-01-19 2020-06-09 罗普特科技集团股份有限公司 Image data synchronization method, device and system
CN113495883A (en) * 2020-03-20 2021-10-12 华为技术有限公司 Data storage method and device for database

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103442042A (en) * 2013-08-14 2013-12-11 福建天晴数码有限公司 Incremental data synchronization method and system
CN103440317A (en) * 2013-08-28 2013-12-11 电子科技大学 Incremental data inquiry method based on database time labels
CN104133852A (en) * 2014-07-04 2014-11-05 小米科技有限责任公司 Webpage access method, webpage access device, server and terminal
CN105045881A (en) * 2015-07-21 2015-11-11 上海融甸信息科技有限公司 Historical data adding method
CN105468623A (en) * 2014-09-03 2016-04-06 阿里巴巴集团控股有限公司 Data processing method and apparatus
CN107656970A (en) * 2017-08-31 2018-02-02 郑州云海信息技术有限公司 A kind of method of data synchronization, device and server
CN107784086A (en) * 2017-10-09 2018-03-09 中国平安人寿保险股份有限公司 A kind of loading method of webpage, terminal device and computer-readable recording medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5061166B2 (en) * 2009-09-04 2012-10-31 Kii株式会社 Data synchronization system and data synchronization method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103442042A (en) * 2013-08-14 2013-12-11 福建天晴数码有限公司 Incremental data synchronization method and system
CN103440317A (en) * 2013-08-28 2013-12-11 电子科技大学 Incremental data inquiry method based on database time labels
CN104133852A (en) * 2014-07-04 2014-11-05 小米科技有限责任公司 Webpage access method, webpage access device, server and terminal
CN105468623A (en) * 2014-09-03 2016-04-06 阿里巴巴集团控股有限公司 Data processing method and apparatus
CN105045881A (en) * 2015-07-21 2015-11-11 上海融甸信息科技有限公司 Historical data adding method
CN107656970A (en) * 2017-08-31 2018-02-02 郑州云海信息技术有限公司 A kind of method of data synchronization, device and server
CN107784086A (en) * 2017-10-09 2018-03-09 中国平安人寿保险股份有限公司 A kind of loading method of webpage, terminal device and computer-readable recording medium

Also Published As

Publication number Publication date
CN110413684A (en) 2019-11-05

Similar Documents

Publication Publication Date Title
US9690568B2 (en) Client-side script bundle management system
CN111399756B (en) Data storage method, data downloading method and device
CN112559927B (en) Webpage loading method and device
CN107566857B (en) Video downloading method, device, system, server and terminal
CN110275983A (en) The search method and device of traffic monitoring data
CN111221469B (en) Method, device and system for synchronizing cache data
CN103699597A (en) Method for downloading file through browser and browser
CN104202387A (en) Metadata recovery method and related device
CN110413684B (en) Database synchronization method, device and system
KR102233867B1 (en) Extracting similar group elements
CN111414743B (en) Method and device for calling document template, electronic equipment and storage medium
US10938773B2 (en) Method and apparatus for synchronizing contact information and medium
CN109657164B (en) Method, device and storage medium for publishing message
CN111383038A (en) Advertisement display method and device of mobile terminal, mobile terminal and storage medium
CN103678535A (en) Browser and downloading method thereof
CN111131497B (en) File transmission method and device, electronic equipment and storage medium
CN107103001B (en) Method, device and system for acquiring target front-end resource file based on browser
CN111159244B (en) Data query method and device
CN111125142B (en) Data updating method and system
CN103702208A (en) Data broadcasting system based on user action prediction and data acceleration method thereof
CN103914477A (en) Method and device for processing data
CN113111042A (en) Archive file management method and system and electronic equipment
CN109951613B (en) Image transmitting method, image receiving method, image transmitting device, image receiving device, electronic device, and storage medium
US20220075928A1 (en) Rendering method for on-demand loading of pdf file on network
CN111221781A (en) Data searching method and device, electronic equipment and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20200325

Address after: 310051 room 307, floor B, building 2, No. 399, Danfeng Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Hangzhou Haikang Storage Technology Co.,Ltd.

Address before: 430074 East Lake Development Zone, Wuhan City, Hubei Province, No. 1 Software Park, Guanshan Road, Phase 5, Building F4, Room 21, Room 01

Applicant before: WUHAN HIKSTORAGE TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant