Disclosure of Invention
The embodiment of the disclosure provides an updating method, device and system of an installation package, which can solve the problem of low updating efficiency of the installation package in the related art. The technical scheme is as follows:
in one aspect, a method for updating an installation package is provided, which is applied to a terminal, and the method includes:
acquiring the current time as a first initial time after the terminal is started;
updating the first initial time based on the operation time of the terminal to obtain a first target time, wherein the size of the first target time is positively correlated with both the operation time and the first initial time;
and sending a detection request aiming at the installation package to a server at the first target moment, wherein the detection request is used for indicating the server to detect whether an updated version of the installation package exists or not.
Optionally, the updating the first initial time based on the operation duration of the terminal to obtain a first target time includes:
updating the first initial time for N times based on the running time of the terminal at N different times to obtain a first target time, wherein N is an integer greater than 1;
the size of the updated first initial time obtained based on the operation time length of the terminal at the ith time is positively correlated with the operation time length at the ith time, i is a positive integer less than or equal to N, and the size of the first target time is positively correlated with the size of the first initial time after the nth update.
Optionally, the first initial time T after the ith updateiSatisfies the following conditions: t isi=(k×Ti-1+ti-1)s;
Wherein k is a prime number, and t isi-1And the operation duration of the terminal at the (i-1) th moment is shown, wherein s is a positive integer.
Optionally, the first target time h1 satisfies:
wherein, T isNAnd M is an integer larger than 1 at the first initial moment after the Nth updating.
Optionally, M is equal to N.
Optionally, the method further includes:
after the first target moment sends a detection request for the installation package to the server, acquiring the current moment as a second initial moment;
determining a second target time based on the second initial time and the interval duration, wherein the second target time is positively correlated with both the size of the second initial time and the interval duration;
and the step of sending the detection request for the installation package to the server is executed again at the second target moment.
Optionally, the second target time h2 satisfies: h2 ═ w + z;
wherein w is the second initial time, and z is the interval duration.
In another aspect, an apparatus for updating an installation package is provided, where the apparatus is applied to a terminal, and the apparatus includes:
the terminal comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring the current moment as a first initial moment after the terminal is started;
the updating module is used for updating the first initial time based on the running time of the terminal to obtain a first target time, and the size of the first target time is positively correlated with both the running time and the first initial time;
a sending module, configured to send, to a server at the first target time, a detection request for an installation package, where the detection request is used to instruct the server to detect whether an updated version of the installation package exists.
In yet another aspect, a computer-readable storage medium is provided, having instructions stored therein, the instructions being loaded and executed by a processor to implement the update method of an installation package as described in the above aspect.
In still another aspect, an update apparatus for an installation package is provided, where the update apparatus for an installation package includes a processor and a memory, and the memory stores instructions that are loaded and executed by the processor to implement the update method for an installation package according to the above aspect.
In a further aspect, there is provided a computer program product containing instructions which, when run on the computer, cause the computer to perform the method of updating an installation package as described in the preceding aspect.
In yet another aspect, an update system for an installation package is provided, the system including: a terminal and a server;
the terminal comprises an updating device of the installation package according to the above aspect;
the server is used for detecting whether an updated version of the installation package exists or not based on a detection request for the installation package sent by the terminal.
The beneficial effects brought by the technical scheme provided by the embodiment of the disclosure at least comprise:
the embodiment of the disclosure provides an updating method, device and system of an installation package, a terminal can update a first initial time based on the running time of the terminal to obtain a first target time, and the size of the first target time is positively correlated with the running time and the first initial time. Because the performance of different terminals and the environment (for example, the temperature around the terminal) are different, the operating time lengths determined by the different terminals are different from the first initial time, and further, the first target time obtained by updating the first initial time by the different terminals based on the operating time lengths is different. Therefore, the method can prevent a plurality of terminals from sending the detection request aiming at the installation package to the server at the same time, thereby effectively reducing the pressure of the server and improving the updating efficiency of the installation package.
Detailed Description
To make the objects, technical solutions and advantages of the present disclosure more apparent, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
Fig. 1 is a schematic diagram of an update system of an installation package according to an embodiment of the present disclosure, and as shown in fig. 1, the system may include a plurality of terminals 10 and a server 20. Fig. 1 exemplifies that the system includes two terminals 10.
Wherein, the connection between each terminal 10 and the server 20 can be established through a wired network or a wireless network.
The terminal 10 may be a desktop computer, a vehicle-mounted terminal, a mobile terminal, a wearable device, or an intelligent home device, and the like, which is equipped with an operating system and an application. The server 20 may be a server, a server cluster composed of several servers, or a cloud computing service center.
Fig. 2 is a flowchart of an update method of an installation package according to an embodiment of the present disclosure, where the method may be applied to the terminal 10 shown in fig. 1. As shown in fig. 2, the method may include:
step 201, acquiring the current time as a first initial time after the terminal is powered on.
In this embodiment of the present disclosure, a first function used for obtaining the current time may be stored in the terminal in advance, and the first function may be: currenttimeMillis (). The terminal can operate the first function after being started, and the current time is obtained through the first function and is used as the first initial time. Optionally, the statistical accuracy of the first initial time may be in milliseconds.
Step 202, updating the first initial time based on the running time of the terminal to obtain a first target time.
After the terminal acquires the first initial time, the first initial time may be updated based on the operation duration of the terminal, so as to obtain a first target time. The size of the first target time is positively correlated with both the operation duration and the size of the first initial time.
Optionally, a second function for determining the operation duration of the terminal may be stored in the terminal in advance, and the operation duration of the terminal determined by the second function may be a duration from the time when the terminal is powered on to the current time. It will be appreciated that the terminal determines different operating durations at different times by means of the second function. The second function may be system.
Step 203, sending a detection request aiming at the installation package to the server at the first target time.
After obtaining the first target time, the terminal may send a detection request for the installation package to the server at the first target time, where the detection request is used to instruct the server to detect whether an updated version of the installation package exists.
Optionally, the detection request may carry a version number of the installation package and an identifier of the installation package, where the identifier of the installation package may be a name of the installation package. After receiving the detection request, the server may detect whether an updated version exists in the installation package identical to the identifier based on the identifier of the installation package and the version number of the installation package. If the installation package identical to the identifier has an updated version, the server can determine that the installation package has the updated version, so that the installation package with the updated version can be sent to the terminal, and the terminal can update the installation version. If the installation package same with the identifier does not have the updated version, the server can enable the installation package not to have the updated version, and therefore prompt information can be sent to the terminal and used for prompting the terminal that the installation package does not have the updated version.
To sum up, the embodiment of the present disclosure provides an update method for an installation package, where a terminal may update a first initial time based on an operation duration of the terminal to obtain a first target time, and a size of the first target time is positively correlated to both the operation duration and the first initial time. Because the performance of different terminals and the environment (for example, the temperature around the terminal) are different, the operating time lengths determined by the different terminals are different from the first initial time, and further, the first target time obtained by updating the first initial time by the different terminals based on the operating time lengths is different. Therefore, the method can prevent a plurality of terminals from sending the detection request aiming at the installation package to the server at the same time, thereby effectively reducing the pressure of the server and improving the updating efficiency of the installation package.
Fig. 3 is a flowchart of another installation package updating method provided by the embodiment of the present disclosure, which may be applied to the installation package updating system shown in fig. 1. As shown in fig. 3, the method may include:
step 301, the terminal acquires the current time as a first initial time after being powered on.
In this embodiment of the present disclosure, a first function used for obtaining the current time may be stored in the terminal in advance, and the first function may be: currenttimeMillis (). The terminal may operate the first function after being powered on to obtain the current time as a first initial time, and the statistical accuracy of the first initial time may be in milliseconds.
Step 302, the terminal updates the first initial time for N times based on the running time at N different times to obtain a first target time.
The terminal may be pre-stored with a second function for determining the operation duration of the terminal, and the operation duration of the terminal determined by the second function may be a duration from the time when the terminal is powered on to the current time. It will be appreciated that the terminal determines different operating durations at different times by means of the second function. The second function may be system.
After the terminal acquires the first initial time, the first initial time may be updated based on the operation duration of the terminal, so as to obtain a first target time. And the size of the first target time is positively correlated with the operation time of the terminal and the size of the first initial time.
Optionally, the terminal may obtain the operation durations of the terminal at N different times, and may update the first initial time N times based on the operation durations of the terminal at N different times to obtain the first target time.
Wherein N may be an integer greater than 1. The size of the updated first initial time obtained based on the operation time of the terminal at the ith time is positively correlated with the operation time of the ith time, the ith time is the time when the terminal operates the second function for the ith time after being electrified and determines the operation time, and i is a positive integer less than or equal to N. The size of the first target time is positively correlated with the size of the first initial time after the Nth update.
Optionally, N is less than or equal to a number threshold, where the number threshold is the maximum number of times that the terminal can update the first initial duration based on the running duration of the terminal within the duration threshold. The number threshold is positively correlated with the duration threshold.
The duration threshold is the maximum duration from the current time acquired by starting the terminal as the first initial time to the first target time, that is, the terminal needs to send a detection request for the installation package to the server within the duration threshold from the time when the first initial time is determined. Therefore, the terminal can send the detection request aiming at the installation package to the server in time after being started, and the reliability of updating the installation package is further ensured.
In the embodiment of the present disclosure, the greater the N is, the higher the reliability of the first target time determined by the terminal within the time length threshold is, and thus the higher the dispersion of the first target time determined by different terminals within the time length threshold is.
Assuming that the server can process the request 1 ten thousand times per second, if different terminals determine the first target time for sending the detection request to the server by using the method provided by the embodiment of the disclosure, the server can process the detection requests sent by 2000 ten thousand terminals in time within 6 hours, and the downtime cannot occur.
The number threshold and the duration threshold are fixed values pre-stored in the terminal, the number threshold g is y × 60 × 6, g and y are integers greater than 1, y is a duration threshold, the statistical accuracy of y is hour, 60 minutes is indicated by 60 minutes, and 6 is the number of times that the terminal can send a detection request to the server per minute.
For example, if the duration threshold is 6 hours, i.e., y is equal to 6, the number threshold g is equal to 2160, and N may be equal to the number threshold 2160.
In the embodiment of the present disclosure, the first initial time T after the ith updateiSatisfies the following conditions: t isi=(k×Ti-1+ti-1)s. Wherein k is a prime number, ti-1The operation duration of the terminal at the (i-1) th moment is shown, and s is a positive integer. Illustratively, k may be 97 and s may be 3.
It can be understood that T0The method includes the steps that the current time obtained by running the first function for the 1 st time after the terminal is started is obtained, namely the first initial time obtained for the first time after the terminal is started. The t is0The running time length t determined by running the second function for the 1 st time after the terminal is powered on0Also known as a terminalThe running time of the terminal at the 0 th time.
Assuming that N is 2160, k is 97, and s is 3, when i is equal to 1, the first initial time T after the 1 st update1Satisfies the following conditions: t is1=(97×T0+t0)3. The first initial time T after the 2 nd update when i is equal to 22Satisfies the following conditions: t is2=(97×T1+t1)3. The t is1The running time of the terminal at the 1 st moment is shown. And repeating the steps until the terminal determines the first initial moment after the Nth updating.
In the disclosed embodiment, the first target time h1 satisfies:
wherein, the TNAnd M is an integer larger than 1 at the first initial moment after the Nth updating. Optionally, M may be less than or equal to the number threshold. For example, if the duration threshold is 6 hours, then M may be 2160.
Alternatively, M may be equal to N. For example, M and N may both be 2160.
Because the performance of different terminals and the environment (for example, the temperature around the terminal) are different, the operation durations determined by the different terminals at each time are different, and further, the size of the first initial time after updating obtained based on the operation duration at the time is also different, so that the first initial time after the nth updating obtained by the first initial time is also different, and the first target time finally determined is also necessarily different. Different terminals can effectively ensure that the first target time for sending the detection request to the server by the different terminals is different, so that the situation that a plurality of terminals send the detection request aiming at the installation package to the server at the same time is effectively avoided, the pressure of processing the detection request by the server is effectively reduced, and the updating efficiency of the installation package is improved.
Step 303, the terminal sends a detection request for the installation package to the server at the first target time.
After obtaining the first target time, the terminal may send a detection request for the installation package to the server at the first target time. Wherein the detection request is used for instructing the server to detect whether the updated version of the installation package exists.
Optionally, the detection request may carry a version number of the installation package and an identifier of the installation package, where the identifier of the installation package may be a name of the installation package. After receiving the detection request, the server may detect whether an updated version exists in the installation package identical to the identifier based on the identifier of the installation package and the version number of the installation package. If the installation package identical to the identifier has an updated version, the server can determine that the installation package has the updated version, so that the installation package with the updated version can be sent to the terminal, and the terminal can update the installation version. If the installation package same with the identifier does not have the updated version, the server can enable the installation package not to have the updated version, and therefore prompt information can be sent to the terminal and used for prompting the terminal that the installation package does not have the updated version.
And step 303, the terminal acquires the current time as a second initial time.
After the terminal sends the detection request for the installation package to the server at the first target time, the current time can be acquired as a second initial time. Optionally, the terminal may obtain the current time as the second initial time by operating the first function.
And step 304, the terminal determines a second target time based on the second initial time and the interval duration.
After acquiring the current time as the second initial time, the terminal may determine the second target time based on the second initial time and the interval duration. The size of the second target time and the second initial time and the interval duration are both positively correlated, and the interval duration may be a fixed duration pre-stored in the terminal. For example, the interval duration may be 10000 milliseconds.
In the disclosed embodiment, the second target time h2 may satisfy: h2 ═ w + z, where w is the second initial time and z is the interval duration.
And 305, the terminal sends a detection request aiming at the installation package to the server at a second target time.
After determining the second target time, the terminal may send a detection request for the installation package to the server again at the second target time.
In the embodiment of the present disclosure, after the terminal sends the detection request for the installation package to the server at the first target time, if the updated version of the installation package sent by the server is received and the installation package is updated, the terminal sends the detection request for the installation package to the server again at the second target time (the detection request carries the version number of the updated version of the installation package, that is, the detection request for the updated installation package in the detection request), so that the updated version of the updated installation package can be obtained in time when the updated version of the updated installation package exists in the server, thereby ensuring the timeliness of updating the updated installation package. If the updated version of the installation package sent by the server is not received, the detection request for the installation package is sent to the server again at the second target moment, so that the terminal can be ensured to acquire the updated version of the installation package in time, and the installation package is ensured to be updated in time.
In the embodiment of the present disclosure, after the terminal sends the detection request for the installation package to the server at the second target time, the above steps 304 to 306 may be repeatedly executed until a shutdown instruction for the terminal is received. Therefore, before the terminal receives the shutdown instruction, the terminal can periodically send the detection request aiming at the installation package to the server, and the timeliness and the reliability of updating the installation package are further ensured.
In the embodiment of the present disclosure, the terminal may update the first initial time N times based on the running durations at N different times, so as to obtain the first target time. Or updating the first initial time obtained for the first time to obtain the first target time based on the running time of the first initial time. Accordingly, M may be 1.
It should be noted that, the order of the steps of the update method of the installation package provided in the embodiment of the present application may be appropriately adjusted, and the steps may also be deleted according to the situation, for example, the above-mentioned steps 304 to 306 may be deleted according to the situation. Any method that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application is covered by the protection scope of the present application, and thus the detailed description thereof is omitted.
To sum up, the embodiment of the present disclosure provides an update method for an installation package, where a terminal may update a first initial time based on an operation duration of the terminal to obtain a first target time, and a size of the first target time is positively correlated to both the operation duration and the first initial time. Because the performance of different terminals and the environment (for example, the temperature around the terminal) are different, the operating time lengths determined by the different terminals are different from the first initial time, and further, the first target time obtained by updating the first initial time by the different terminals based on the operating time lengths is different. Therefore, the method can prevent a plurality of terminals from sending the detection request aiming at the installation package to the server at the same time, effectively reduces the pressure of the server and improves the updating efficiency of the installation package.
Fig. 4 is a block diagram of an update apparatus for an installation package according to an embodiment of the present disclosure. The apparatus may be applied to the terminal 10 shown in fig. 1. As shown in fig. 4, the apparatus may include:
an obtaining module 401, configured to obtain a current time as a first initial time after the terminal is powered on.
An updating module 402, configured to update the first initial time based on the operation duration of the terminal to obtain a first target time, where the size of the first target time is positively correlated to both the operation duration and the size of the first initial time.
A sending module 403, configured to send, to the server at the first target time, a detection request for the installation package, where the detection request is used to instruct the server to detect whether an updated version of the installation package exists.
To sum up, the embodiment of the present disclosure provides an update apparatus for an installation package, where a terminal may update a first initial time based on an operation duration of the terminal to obtain a first target time, and a size of the first target time is positively correlated to both the operation duration and the first initial time. Because the performance of different terminals and the environment (for example, the temperature around the terminal) are different, the operating time lengths determined by the different terminals are different from the first initial time, and further, the first target time obtained by updating the first initial time by the different terminals based on the operating time lengths is different. Therefore, the method can prevent a plurality of terminals from sending the detection request aiming at the installation package to the server at the same time, effectively reduces the pressure of the server and improves the updating efficiency of the installation package.
The update module 402 is configured to:
and updating the first initial time for N times based on the running time of the terminal at N different times to obtain a first target time, wherein N is an integer greater than 1.
The size of the first initial time after updating is obtained based on the operation time length of the terminal at the ith time and positively correlated with the operation time length at the ith time, the size of the first target time is positively correlated with the size of the first initial time after updating for the Nth time, and i is a positive integer less than or equal to N.
Optionally, the first initial time T after the ith updateiSatisfies the following conditions: t isi=(k×Ti-1+ti-1)s。
Wherein k is a prime number, ti-1The operation duration of the terminal at the (i-1) th moment is shown, and s is a positive integer.
Optionally, the first target time h1 satisfies:
wherein, TNAnd M is an integer larger than 1 at the first initial moment after the Nth updating.
Optionally, M is equal to N.
Optionally, the obtaining module 401 is further configured to obtain the current time as a second initial time after sending the detection request for the installation package to the server at the first target time.
Referring to fig. 5, the apparatus may further include: a determining module 404, configured to determine a second target time based on the second initial time and the interval duration, where the second target time is positively correlated to both the size and the interval duration of the second initial time.
A sending module 403, configured to execute the step of sending the detection request for the installation package to the server again at the second target time.
Optionally, the second target time h2 satisfies: h2 ═ w + z.
Wherein w is the second initial time, and z is the interval duration.
To sum up, the embodiment of the present disclosure provides an update apparatus for an installation package, where a terminal may update a first initial time based on an operation duration of the terminal to obtain a first target time, and a size of the first target time is positively correlated to both the operation duration and the first initial time. Because the performance of different terminals and the environment (for example, the temperature around the terminal) are different, the operating time lengths determined by the different terminals are different from the first initial time, and further, the first target time obtained by updating the first initial time by the different terminals based on the operating time lengths is different. Therefore, the method can prevent a plurality of terminals from sending the detection request aiming at the installation package to the server at the same time, effectively reduces the pressure of the server and improves the updating efficiency of the installation package.
The disclosed embodiments provide a computer-readable storage medium, in which instructions are stored, and the instructions are loaded and executed by a processor to implement the update method of the installation package as the above embodiments. For example, the update method of the installation package shown in fig. 2 or fig. 3.
The embodiment of the present disclosure provides an update apparatus 50 of an installation package, and as shown in fig. 6, the update apparatus 50 of the installation package may include a processor 501 and a memory 502. The memory 502 stores instructions that are loaded and executed by the processor 501 to implement the update method of the installation package as in the above embodiments. For example, the update method of the installation package shown in fig. 2 or fig. 3.
The embodiment of the present disclosure provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the update method of the installation package as the above embodiment. For example, the update method of the installation package shown in fig. 2 or fig. 3.
The embodiment of the present disclosure provides an update system of an installation package, which may include a terminal 10 and a server 20, as shown in fig. 1. The terminal may comprise the updating means 40 of the installation package shown in fig. 4 or 5. Or the terminal 10 may be the update device 50 of the installation package shown in fig. 6.
The server 20 is configured to detect whether there is an updated version of the installation package based on a detection request for the installation package transmitted by the terminal 10.
In the disclosed embodiments, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The term "plurality" in the embodiments of the present disclosure means two or more.
The above description is intended to be exemplary only and not to limit the present disclosure, and any modification, equivalent replacement, or improvement made without departing from the spirit and scope of the present disclosure is to be considered as the same as the present disclosure.