Data updating method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for updating data.
Background
Currently, in practical applications, there are some category data with a small update frequency and an unfixed update time, such as news category data in a certain news Application (APP). It is assumed that category data in the news APP includes category data of entertainment type, military type, social type, and the like. If the staff of the news APP finds that the click rate of the user on the entertainment type news is small after performing data statistics on the click rate of the recent user on various types of news, the staff can modify the category information of the news content in the server and directly delete the entertainment type news data.
In order to ensure that after modifying the category data in the server, the category data displayed in the news APP is consistent with the updated category data in the server, in the prior art, the following two methods are generally adopted to make the category data displayed in the news APP consistent with the updated category data in the server:
the method comprises the following steps: after the server establishes long connection with the news APP, if the server updates the category data, the server sends the updated data to the news APP. When the news APP receives the data, the data is stored locally. When the user opens the user operation interface displaying the category data, the user operation interface displays the updated data. However, this method has certain disadvantages: the news APP may not be able to display category data normally.
This is because in practical applications, different versions of APPs are usually developed for different platforms or operating systems, and even for the same platform and the same operating system. Since different versions of APP may only support data in one or several formats, the server stores data in different formats for categories. After the long connection is established between the news APP and the server, if the server cannot acquire the version information of the news APP, the server will randomly send the category data in a certain format to the news APP, which may cause the news APP to be incapable of analyzing the category data in the certain format, so that the news APP cannot normally display the category data.
The second method comprises the following steps: as long as the user opens the operation interface for displaying the category data in the news APP, the news APP actively sends a data updating request to the server, and the server sends the latest data to the client according to the data updating request. The data updating request comprises the version information of the news APP, so that the news APP can send the category data matched with the version of the news APP according to the version information of the news APP contained in the data updating request.
However, the second method has other disadvantages: the waste of network resources.
This is because, when the server does not update the data, the news APP still sends a data update request to the server, and finally the category data displayed by the news APP does not change. This results in a waste of network resources.
Disclosure of Invention
The embodiment of the application provides a method and a device for updating data, which are used for solving the problem of waste of network resources in a method for updating category data in the prior art.
The embodiment of the application adopts the following technical scheme:
a method of updating data, comprising:
after the category data is updated, the server sends a data updating instruction to the client;
receiving a data updating request returned by the client according to the data updating instruction;
and sending the updated category data to the client according to the data updating request.
A method of updating data, comprising:
a client receives a data updating instruction sent by a server, wherein the data updating instruction is sent to the client by the server after the category data is updated;
sending a data updating request to the server according to the data updating instruction;
and receiving the updated category data returned by the server according to the data updating request.
An update data device, comprising:
the instruction sending module is used for sending a data updating instruction to the client by the server after the category data is updated;
the request receiving module is used for receiving a data updating request returned by the client according to the data updating instruction;
and the data sending module is used for sending the updated category data to the client according to the data updating request.
An update data device, comprising:
the client receives a data updating instruction sent by a server, wherein the data updating instruction is sent to the client by the server after the category data is updated;
the request sending module is used for sending a data updating request to the server according to the data updating instruction;
and the data receiving module is used for receiving the updated category data returned by the server according to the data updating request.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects:
in the prior art, as long as the client displays the category data, the client actively sends a data update request to the server, so that the server sends the latest category data, which may cause waste of network resources. In the embodiment of the application, after receiving the data updating instruction sent by the server, the client sends the data updating request to the server, so that the server sends the updated category data to the client. Therefore, the method in the embodiment of the application solves the problem of network resource waste in the method for sending the updated category data in the prior art.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1a is a schematic flowchart illustrating an implementation process of a method for updating data according to an embodiment of the present application;
FIG. 1b is a bill category data display page provided by an embodiment of the present application;
fig. 1c is a display page of whether to update data according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of an apparatus for updating data according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of another data updating apparatus according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
In order to solve the problem of waste of network resources in a method for updating category data in the prior art, an embodiment of the present application provides a method for updating data.
The specific flow diagram of the method is shown in fig. 1a, and comprises the following steps:
and step 11, after the category data is updated, the server sends a data updating instruction to the client.
The data updating method provided by the embodiment of the application can be used for updating the category data. The category data may be category data with a low update frequency and a non-fixed update time. Data with a low update frequency and a non-fixed update time may include, but is not limited to, billing category data in a payment platform or news category data in a news APP, etc. Of course, other types of category data may be updated, such as category data with a faster update frequency or a fixed update time.
The billing category data in the payment platform may include, but is not limited to, shopping type, catering type, water and electricity type, or telephone rate type, for example. As shown in fig. 1b, the data shown in fig. 1b is the bill category data in a certain payment platform, and if the user wishes to view the recent consumption record about the catering aspect, the user can click on "catering" in the page, so as to view the relevant consumption record.
Since the category data shown in fig. 1b is provided by the server, the category data in the client is consistent with the category data in the server. After the data in the server is updated, in order to keep the category data in the client consistent with the category data in the server, the server may send a data update instruction to the client to notify the client that the category data in the server has been updated, so that the client completes subsequent operations according to the instruction, and finally obtains the updated category data.
It should be noted that, only when the connection is established between the server and the client, the server can send a data update instruction to the client; if the connection between the server and the client is not established, the server cannot send a data updating instruction to the client. The connection established between the server and the client may be a long connection or a short connection, which is not limited in this embodiment of the present application. Specifically, the server may send the data update instruction to the client immediately when monitoring that the client is started and establishes a connection with the server, or may send the data update instruction to the client when monitoring that the client is started and opens an interface for displaying the category data (when the client opens the interface for displaying the category data, the client may send a preset message to the server so that the server knows that the client has opened the interface for displaying the category data).
And step 12, the server receives a data updating request returned by the client according to the data updating instruction.
After receiving the data update command, the client sends a data update request to the server, so that the server receives the data update request and continues to execute step 13.
Specifically, the client may send the data update request to the server immediately after receiving the data update instruction, or may not send the data update request after receiving the data update instruction, but send the data update request to the server when determining that a certain condition is satisfied. For example, after receiving the data update instruction, the client may send a request to the server when opening an interface for displaying category data, or may send a data update request to the server when determining that the user clicks a certain control in the client after receiving the data update instruction.
Along the above example, as shown in fig. 1c, after the client receives the data update instruction, a prompt inquiring whether to update data may be displayed on the operation interface of the client, and if the user clicks the determination control, the client sends a data update request to the server; and if the user clicks the rejection control, the data updating request is not sent to the server for the moment.
And step 13, the server sends the updated category data to the client according to the data updating request.
In the embodiment of the application, the data update request sent by the client to the server may include version information of the client. Therefore, after receiving the data updating request, the server can send the updated category data matched with the version information to the client according to the version information.
And after the client receives the updated category data sent by the server, the updated category data can be adopted to update the category data locally stored by the client.
In the method, the server sends the data updating instruction to the client only after the category data is updated, the client returns the data updating request according to the received data updating instruction, the server sends the category data to the client after receiving the data updating request, and the network resources consumed by the server for sending the data updating instruction to the client are generally far less than the network resources consumed by the server for sending the category data to the client.
In step 11 shown in fig. 1a, after one update, the server may send a data update command to the client whenever the server and the client are changed from the unconnected state to the connected state before the next update. According to the method shown in fig. 1a, when the client receives the data update instruction, the client returns a data update request, and the server sends updated data to the client according to the data update request, which may cause a problem of unnecessary resource waste because the client needs to repeatedly update data when establishing connection with the server again after having updated the data.
In order to avoid the problem of resource waste, after the category data is updated, the server may send a data update instruction corresponding to the updated category data to the client, where if the updated category data is different, the corresponding data update instructions are also different. Specifically, the data update instruction corresponding to the updated category data may carry a version number corresponding to the updated category data, or an MD5 value corresponding to the updated category data, or the like, as long as it is ensured that the updated category data only corresponds to one globally unique data update instruction.
Correspondingly, when receiving a data updating instruction sent by the server, the client firstly determines whether the data updating instruction exists in a log recorded in the local by the client, and if so, the client does not send a data updating request to the server; if the data does not exist, the data updating instruction is recorded in a local log, and a data updating request is sent to the server, so that the server returns the updated data.
For example, assuming that a data update instruction recorded in a local log by a client is a data update instruction carrying version numbers v1 and v2, at this time, data in a server is updated, and the updated data version number is v3, after the data is updated, the server sends a data update instruction carrying version number v3 to the client, and after the client receives the data update instruction, it is determined that the data update instruction carrying version number v3 does not exist in the local log, the data update instruction carrying version number v3 is recorded in the local log, and a data update request is sent to the server, so that the server returns the updated data. If the client is closed and started again in the following, and connection is established with the server, the server will send the data update instruction carrying the version number v3 to the client again, and at this time, after receiving the data update instruction carrying the version number v3, the client will determine that the data update instruction carrying the version number v3 already exists in the local log, and therefore, no data update request is sent to the server, so that unnecessary data update is avoided, and unnecessary resource waste is also avoided.
In addition, in practical application, a situation that the client cannot receive a data update instruction sent by the server may occur due to a network failure or the like, and if the client is the client that is just installed by the user at this time, the category data locally stored by the client only has preset default category data, or even does not store any category data, the client cannot normally display the updated category data. Therefore, in the embodiment of the application, except that the client sends the data update request to the server after receiving the data update instruction sent by the server, if the client does not receive the data update instruction sent by the server, but the client does not locally store the category data, or the category data locally stored by the client is preset default category data, the client may also send the data update request to the server, so that the server returns the updated category data to the client according to the data update request.
Based on the same idea, the present application further provides a device for updating data.
As shown in fig. 2, a schematic structural diagram of a data updating apparatus provided in an embodiment of the present application mainly includes the following apparatuses:
the instruction sending module 21 is used for sending a data updating instruction to the client by the server after the category data is updated;
a request receiving module 22, configured to receive a data update request returned by the client according to the data update instruction;
and the data sending module 23 is configured to send the updated category data to the client according to the data updating request.
In one embodiment, the instruction sending module 21 sends a data update instruction to the client when it is determined that the client establishes a connection with the server.
In one embodiment, the instruction sending module 21 sends a data update instruction corresponding to the updated category data to the client.
In one embodiment, the data includes: billing category data.
In the embodiment of the present application, the data updating method provided in the embodiment of the present application may also be implemented by another data updating apparatus.
As shown in fig. 3, a schematic structural diagram of another data updating apparatus provided in the embodiment of the present application mainly includes the following apparatuses:
the instruction receiving module 31 is configured to receive a data updating instruction sent by a server by a client, where the data updating instruction is sent by the server to the client after the category data is updated;
a request sending module 32, configured to send a data update request to the server according to the data update instruction;
and the data receiving module 33 is configured to receive the updated category data returned by the server according to the data updating request.
In an embodiment, the instruction receiving module 31 receives a data update instruction corresponding to the updated category data sent by the server by the client.
Before sending the data update request to the server, the apparatus further includes:
and the instruction determining module is used for determining that the data updating instruction does not exist in the local log recorded by the client.
After determining that the client record does not have the data updating instruction in a local log, the apparatus further includes:
and the instruction recording module is used for recording the received data updating instruction in the log.
In one embodiment, the apparatus further comprises:
and the first updating module is used for sending a data updating request to the server by the client when the client does not receive a data updating instruction sent by the server and if the category data is not locally stored by the client or the locally stored category data is preset default category data, so that the server returns the updated category data to the client according to the data updating request.
In one embodiment, the apparatus further comprises:
and the second updating module is used for updating the category data locally stored by the client by adopting the updated category data.
In one embodiment, the data includes: billing category data.
In the prior art, as long as the client displays the category data, the client actively sends a data update request to the server, so that the server sends the latest data, which may cause waste of network resources. In the embodiment of the application, after receiving the data updating instruction sent by the server, the client sends the data updating request to the server, so that the server sends the updated category data to the client. Therefore, the method in the embodiment of the application solves the problem of network resource waste in the method for updating the category data in the prior art.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that 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 an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.