CN110489444A - A kind of asynchronous query method, apparatus, computer equipment and storage medium - Google Patents
A kind of asynchronous query method, apparatus, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110489444A CN110489444A CN201910777851.XA CN201910777851A CN110489444A CN 110489444 A CN110489444 A CN 110489444A CN 201910777851 A CN201910777851 A CN 201910777851A CN 110489444 A CN110489444 A CN 110489444A
- Authority
- CN
- China
- Prior art keywords
- predetermined time
- result
- interface
- time interval
- query
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a kind of asynchronous query method, apparatus, computer equipment and storage mediums, wherein after the asynchronous query method is comprising steps of call submission data-interface to carry out data submission, recalls query result interface and carries out result queries;If do not inquire as a result, if at predetermined time intervals interval call one query result interface carry out result queries;Wherein, the control strategy of the predetermined time interval is as follows: if it is fixed value that the predetermined time interval, which within the first predetermined time, is arranged, in current time;If current time is more than the first predetermined time range, the increase based on the number for calling query result interface is set, and increases the predetermined time interval.Based on above-mentioned control strategy, enquiry frequency can be improved in the stage that early period may inquire result, and reduce enquiry frequency in stage, to ensure to inquire in time as a result, reducing invalid inquiry again.
Description
Technical field
The present invention relates to data processing field, in particular to a kind of asynchronous query method, apparatus, computer equipment and storage
Medium.
Background technique
In the prior art, there is the platform of many externally offer interface services, although the technology that different platforms uses has
Institute is different, but these interface services provided have a characteristic, i.e., are all asynchronous submission data, for calling query interface side
For, it is actually uncertain when to be inquired, if using triggering inquiry manually, it is clear that will cause user experience
The problem of decline, and majority of case can not all inquire result;If do not had using timing or poll inquiry, enquiry frequency
Determine standard, and no matter frequency height, all unavoidable most of inquiry operations are all to inquire in vain, occupy server money
Source and bandwidth.
Therefore, how querying method is optimized to realize to inquire result in time, reduce invalid inquiry again and be
The current technical issues that need to address of those skilled in the art.
Summary of the invention
The object of the present invention is to provide a kind of asynchronous query method, apparatus, computer equipment and storage medium, Optimizing Queries
Method can inquire result, the again invalid inquiry of reduction to realize in time.
In a first aspect, the embodiment of the invention provides a kind of asynchronous query methods comprising step:
It calls after submitting data-interface to carry out data submission, recalls query result interface and carry out result queries;
If do not inquire as a result, if at predetermined time intervals interval call one query result interface carry out result queries;
Wherein, the control strategy of the predetermined time interval is as follows: if current time within the first predetermined time,
It is fixed value that the predetermined time interval, which is arranged,;If current time is more than the first predetermined time range, setting is looked into based on calling
The increase of the number of result interface is ask, and increases the predetermined time interval.
Second aspect, the embodiment of the invention provides a kind of asynchronous query devices comprising:
First enquiry module, for call submit data-interface carry out data submission after, recall query result interface into
Row result queries;
Second enquiry module, for if do not inquire as a result, if at predetermined time intervals interval call one query result connect
Mouth carries out result queries;
Wherein, the control strategy of the predetermined time interval is as follows: if current time within the first predetermined time,
It is fixed value that the predetermined time interval, which is arranged,;If current time is more than the first predetermined time range, setting is looked into based on calling
The increase of the number of result interface is ask, and increases the predetermined time interval.
The third aspect, the embodiment of the present invention provide a kind of computer equipment again comprising memory, processor and storage
On the memory and the computer program that can run on the processor, the processor execute the computer program
Asynchronous query method described in Shi Shixian first aspect.
Fourth aspect, it is described computer-readable to deposit the embodiment of the invention also provides a kind of computer readable storage medium
It is stored with computer program on storage media, asynchronous query described in first aspect is realized when the computer program is executed by processor
Method.
The embodiment of the invention provides a kind of asynchronous query methods, first call after submitting data-interface to carry out data submission,
It recalls query result interface and carries out result queries;If do not inquire as a result, if at predetermined time intervals interval call one query
As a result interface carries out result queries;Wherein, the control strategy of the predetermined time interval is as follows: if current time is predetermined first
In time range, then it is fixed value that the predetermined time interval, which is arranged,;If current time is more than the first predetermined time range, set
The increase based on the number for calling query result interface is set, and increases the predetermined time interval.Based on above-mentioned control strategy,
Enquiry frequency can be improved in the stage that early period may inquire result, and reduce enquiry frequency in stage, with ensure can
It is inquired in time as a result, reduce invalid inquiry again, the embodiment of the present invention additionally provides a kind of asynchronous query device, computer simultaneously
Equipment and computer readable storage medium have above-mentioned beneficial effect, and details are not described herein.
Detailed description of the invention
Technical solution in order to illustrate the embodiments of the present invention more clearly, below will be to needed in embodiment description
Attached drawing is briefly described, it should be apparent that, drawings in the following description are some embodiments of the invention, general for this field
For logical technical staff, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow diagram of asynchronous query method provided by the embodiment of the present invention;
Fig. 2 is a kind of structural schematic diagram of asynchronous query device provided by the embodiment of the present invention.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
It should be appreciated that the term used in this description of the invention is merely for the sake of for the purpose of describing particular embodiments
And it is not intended to limit the present invention.As description of the invention and it is used in the attached claims, unless up and down
Text clearly indicates other situations, and otherwise " one " of singular, "one" and "the" are intended to include plural form.
It will be further appreciated that the term "and/or" used in description of the invention and the appended claims is
Refer to any combination and all possible combinations of one or more of associated item listed, and including these combinations.
Referring to Fig. 1, Fig. 1 is a kind of flow diagram of asynchronous query method provided by the embodiment of the present invention, such as scheme
It is shown, comprising steps of
S101, it after calling submission data-interface to carry out data submission, recalls query result interface and carries out result queries;
Call submit data-interface submit data after, exactly in order to allow externally provide interface service provider data can be carried out
Processing, to export result.After submitting data, immediately call query result interface carry out result queries (or referred to as inquire, or
Inquiry operation), that is, whether inquire has output result.There are two types of possible situations for above-mentioned movement, and one is inquire as a result, another
It kind is not inquire as a result, then directly terminating querying flow, stopping inquiry the case where for inquiring result.For not inquiring
It the case where to result, is described in detail below.
S102, if do not inquire as a result, if at predetermined time intervals interval call one query result interface carry out result look into
It askes;Wherein, the control strategy of the predetermined time interval is as follows: if current time is arranged within the first predetermined time
The predetermined time interval is fixed value;If current time is more than the first predetermined time range, setting is based on calling inquiry knot
The increase of the number of fruit interface, and increase the predetermined time interval.
Since submission data-interface and query result interface are not the same interface, data-interface is submitted to mention if called
Thousands of data are handed over, and one can only be inquired every time as a result, namely ISP needs centainly data processing
Time, at this moment and when uncertain ISP can have been handled, if encountering network failure, ISP's maintenance
Equal uncertain problems, so when more uncertain ISP can have been handled.Therefore after submitting data, can first it adjust immediately
It is primary with one query result interface polls, but this secondary maximum probability is inquired less than result, in this case, behind need
It to be spaced at predetermined time intervals and one query result interface is called to carry out result queries.It, can be with that is, after submitting data
Inquiry is primary immediately, if do not inquire as a result, if be polled, to inquire result in time.
It is not to be timed poll, this hair according to fixed predetermined time interval always but in the embodiment of the present invention
Bright embodiment pre-sets the control strategy of the predetermined time interval.Its control strategy specifically: if current time exists
Within the scope of first predetermined time, then it is fixed value that the predetermined time interval, which is arranged,;If current time was more than the first predetermined time
The increase based on the number for calling query result interface is then arranged in range, and increases the predetermined time interval.In brief,
Control strategy is exactly fixed predetermined time interval early period, and the later period is gradually increased the predetermined time interval, and with looking into
The increase of number is ask, predetermined time interval increasing degree is bigger.
In general, it after submitting data, can generally export in one section of short period after submission as a result, at this
Between in section (i.e. the first predetermined time range), can be spaced at predetermined time intervals and call one query result interface to carry out result to look into
It askes, i.e., is inquired with fixed enquiry frequency, if do not inquired always this period as a result, still continuing according to above-mentioned pre-
Interval fix time to be inquired, then may all be to inquire in the subsequent most of the time in vain, this will obviously increase service
The resource of device consumption improves cost, so needing to increase predetermined time interval according to control strategy, reduces enquiry frequency.
Specifically, first predetermined time can according to previous experiences in advance fixed (being set in advance as fixed value) or
It is set dynamically according to pre-defined rule.
Specifically, in the embodiment of the present invention, first predetermined time can be fixedly installed in advance according to previous experiences, be
Refer to since current time, obtain the duration that the inquiry operation in the past period for same type finally inquires result,
The duration is exactly the inquiry operation duration that result is spent from starting to query to inquiring of each same type, i.e. inquiry duration,
It is averaged to the above-mentioned each inquiry duration got, (due in the embodiment of the present invention, submits number from starting to query to obtain
It can be inquired immediately after once, so the time started to query namely the time for calling submission data-interface to carry out data submission)
To the average duration for inquiring result, the first predetermined time finally can be determined according to the average duration, it such as can be pre- by first
It fixes time and is set as 1/2 or 2/3 etc. of average duration, such as mean time a length of 50 minutes, then the first predetermined time can
To be set as 25 minutes, a period of time is preferably postponed backward, such as set for the first predetermined time to 30 minutes, to have foot
Enough elasticity, i.e., above-mentioned average duration are also only average value, it is most likely that the case where occurring is actual queries duration above-mentioned flat
Before and after equal duration in a period of time, so can be set for one first retardation time after determining average duration, by the average duration
1/2 or 2/3 add first retardation time, obtain the first final predetermined time.As for first retardation time
Acquisition, can be determined according to statistical result, the overall principle be inquired within the first retardation time the probability of result compared with
It is high.In above-described embodiment, above-mentioned first predetermined time is fixed setting, i.e., once it is determined that good, is just no longer adjusted.The present invention is real
The inquiry operation for the same type being previously mentioned in example is applied, can refer to that submitting to the data of submission data-interface is same type,
The type that may also mean that the result that needs export is same type, may also mean that the mode of processing data is same type
, specifically can according to the actual situation depending on.In addition, it should be noted that needle in the past period need to be obtained in the above process
The duration of result is finally inquired to the inquiry operation of same type, but is that nearest inquiry operation may not looked into there are some situations
It askes as a result, then can directly be rejected for such inquiry operation, only obtaining has the data with inquiry duration.
In concrete application scene, first predetermined time is also possible to dynamic setting, this can make implementation of the present invention
Example is more suitable for continually changing application scenarios, the various possible situations of dynamic adaptation.That is, the embodiment of the present invention is
First predetermined time is arranged in state.As for the mode of dynamic setting, the first predetermined time described in timing adjustment can be, such as
Every an adjustment period modulation primary first predetermined time, which is fixed;It is also possible to not timing tune
Whole first predetermined time, i.e., the adjustment period is not fixed.Specific adjustable strategies are when adjusting every time, from current time
Start, obtains the duration that the inquiry operation in the past period for same type finally inquires result, i.e., inquiry above-mentioned
Duration (duration of result from starting to query to inquiring), is averaged to the above-mentioned inquiry duration got, thus obtain from
The average duration for inquiring result is started to query, finally can determine that the first predetermined time (determined according to the average duration
Mode can determine that averagely 1/2 or the 2/3 of duration adds the retardation time as will be described in the manner previously described).So most
The first predetermined time determined eventually can take into account the inquiry duration in nearest a period of time, so being suitable for inquiry duration
Situation of change (it should be noted that when being fixedly installed for the first predetermined time, can also obtain since " current time " in the past one
Inquiry operation in the section time for same type finally inquires the duration of result, and this step is also to obtain from " current time "
At the time of the case where data of beginning, this " current time " is non-that " current times ", above-mentioned fixed setting is when presetting,
It is a regular time, and this " current time " is then dynamically, as long as the first predetermined time need to be adjusted, then when current
Between at the time of be exactly when adjusting).It should be noted that due in the embodiment of the present invention, the case where for not inquiring result, after
Continuous also to will continue to inquire, this multiple inquiry operation carried out for the same result can be determined as the same inquiry operation, this
The inquiry duration that inventive embodiments are mentioned namely is directed to the duration of same inquiry operation result from starting to query to inquiring.
It is to use periodic ordering system, or use not timing adjustment mode for the first predetermined time, it specifically can basis
The difference of application scenarios is selected, such as under a certain application scenarios, and inquiry duration is the regular variation of comparison, then can be with
Select periodic ordering system, under another application scene, inquiry duration is irregular variation, or even occur to increase suddenly or
The case where reduction, then can choose not timing adjustment mode.For periodic ordering system, the adjustment period can rule of thumb come
It determines, i.e., is determined according to previous data;For not timing adjustment mode, then can according to the past inquiry duration changing rule come
It determining, such as in a period, inquiry duration amplitude of variation is very fast, then and it should reduce and adjust the period, quickening adjustment frequency, and or
In one period of person, inquiry duration amplitude of variation is slower, then can increase the adjustment period, reduces adjustment frequency, specifically, can
To count the duration that the inquiry operation in a period in the past finally inquires result, judge to inquire duration changing rule, from
And the adjustment period is set dynamically.
It should be noted that is be previously mentioned " since current time, obtains the past period in previous embodiment
It is interior ... " the past period therein can be fixed time period, it is also possible to specified time section.Fixed time period therein
It is the period formed since current time to some time point in past, such as current time is August 11:00 on the 6th, when fixed
Between section be 2 days, then the information counted is the information in from August 11:00 on the 4th to 6 this periods of 11:00 of August;Or
Current time is August 11:00 on the 7th, and fixed time period is 2 days, then the information counted is from August 11:00 on the 5th to August 7th
The information of this period of 11:00.Designated time period therein, which refers to, to be formed since current time to specified time in past point
Period, such as current time is August 11:00 on the 6th, and designated time period is from current time to August 11:00 on the 1st (when specified
Between point be August 11:00 on the 1st) period for being formed, then the information counted is this from August 11:00 on the 1st to August 11:00 on the 6th
Information or current time in period are August 11:00 on the 7th, then the information counted is from August 11:00 on the 1st to August
Information in this period of 11:00 on the 7th.The embodiment of the present invention can both use the scheme of above-mentioned fixed time period, can also be with
Using the scheme of above-mentioned designated time period, for different application scene, the two has respective benefit, using fixed time period
The case where scheme will make finally obtained first predetermined time more be bonded nearest a period of time, using the scheme of designated time period,
The case where then having taken into account nearest a period of time, while the case where also taken into account early period.Specifically use which kind of scheme, Ke Yigen
According to the difference of concrete application scene, and different schemes is selected, should finally make the first predetermined time determined more accurate.
In the embodiment of the present invention, within the first predetermined time, the predetermined time interval be it is fixed, i.e., entire
Within the scope of one predetermined time, the predetermined time interval is all constant, although it is inquired within the first predetermined time
As a result probability is higher, but can still have some periods within the first predetermined time, these periods inquire result
Probability it is lower, while can also have other times section, the probability that these periods inquire result is higher, can also exist another
A little periods, the probability that these periods inquire result are medium.So the embodiment of the present invention is preferably, to described
One predetermined time carried out segment processing, i.e., the first predetermined amount of time is divided into several sub- periods in advance, each sub- period
All there is a fixed predetermined time interval, such set-up mode will be closer in practical application scene, to guarantee
It can inquire in time as a result, being avoided that some invalid inquiries again.This setup has important for practical application
Effect is all that higher enquiry frequency is arranged in early period, if that concentrating on some time because if all inquiry operations
Section is submitted, and will lead to the Integrated query within some period below, this obviously will cause server stress abruptly increase, so right
In the first predetermined time, the embodiment of the present invention carries out segment processing to it, and is each sub- period setting one fixed
Predetermined time interval, it will greatly reduce the inquiry pressure of early period, reduce some unnecessary inquiry operations.
As for the division of the first predetermined time, it can be carry out equal part, be also possible to not equal part.It, can if carrying out equal part
To determine the quantity of equal part according to the length of the first predetermined time, so that the length of sub- period is more reasonable, it is unlikely to too long
Or it is too short.If carrying out not equal part, the probability that can be occurred according to query result divides the first predetermined amount of time.
The embodiment of the present invention in the way of not equal part Preferable scheme is that divided for the first predetermined time.Because looking into
The time for asking result is not variation with the time and regular variation, and it is advantageous to carry out not equal part division.Specifically
Ground, counting the time point that previous same type inquiry operation inquires result appears in distribution within the scope of the first predetermined time, example
As in previous same type inquiry operation, 10 times are to concentrate on occurring for 0~5 minute, and 32 times are to concentrate on occurring for 5~8 minutes,
21 times are to concentrate on occurring for 8~12 minutes, and 10 times are to concentrate on occurring for 12~18 minutes, and 38 times are to concentrate on 18~30
Minute occurs.Then the division for carrying out not equal part to the first predetermined time according to distribution, obtain the high section of probability of occurrence and
The low section of probability of occurrence, these sections form the sub- period.One can be arranged in this way for the high section of probability of occurrence
Lower predetermined time interval is that a higher predetermined time interval, obtained section is arranged in the low section of probability of occurrence
It may include multiple, the low section in the section or several probabilities of occurrence that may have several probabilities of occurrence high.
Determination for the second predetermined time, the average duration that aforesaid statistical can be arrived is as the second predetermined time, together
When can also add for the second delay time, i.e., will average duration plus the second delay time as the second predetermined time, exist in this way
Maximum probability can inquire result within the scope of second predetermined time.It is subsequent more than the second predetermined time, then can quickly increase
Add predetermined time interval, reduces enquiry frequency.First delay time and the second delay time can be set to identical or not
Together, it such as can set for the second delay time to twice of the first delay time.Assuming that mean time a length of 50 minutes, the first delay
Time is 5 minutes, then the first predetermined time can be 50*1/2+5=30 minutes, and the second predetermined time can be 50+5*2=60
Minute.
If current time is more than the first predetermined time range, predetermined time interval will be with calling query result interface
The increase of number and increase, that is, call number is more, and the predetermined time is longer, and the interval of calling is also longer.In this way when one
It is not inquired in the section time as a result, need not just be timed poll according to previous interval, but the appropriate interval that increases carries out
Inquiry, in this way can be to avoid most of invalid query actions.
Specifically, the increase of the setting based on the number for calling query result interface, and increase between the predetermined time
Every including:
If within the first predetermined time to the second predetermined time, the predetermined time is arranged in S201, current time
It is identical to be spaced increased amplitude every time;
The purpose of above-mentioned steps is carried out specifically to the situation within the first predetermined time to the second predetermined time
It limits, i.e., in these cases, the increasing degree of predetermined time interval carries out identical.Such as when current time is more than first predetermined
When the time, if its predetermined time interval is n, then will do it to call and look into after this predetermined time interval of past n next time
Result interface is ask to carry out result queries and do not inquired yet as a result, predetermined time interval will be updated to n+m at this time, wherein described
M is the increasing degree of predetermined time interval.So after this predetermined time interval of past n+m, it will do it and adjust next time
Result queries are carried out with query result interface and are not inquired yet as a result, predetermined time interval will be updated to n+2m at this time,
Described in m be predetermined time time interval increasing degree.It, can be into so after this predetermined time interval of past n+2m
Row calls query result interface to carry out result queries next time and is not inquired yet as a result, predetermined time interval will update at this time
For n+3m, wherein the m is the increasing degree of predetermined time time interval.In this way, and so on, the first predetermined time extremely
In the range of second predetermined time, query result interface is called each time, can all update predetermined time interval simultaneously, next time will
Query result interface is called according to the predetermined time interval updated.Finally, until current time is more than the second pre- timing
Between range.
In a concrete application scene, the initial value of the predetermined time interval is less than 10s.That is, adjacent time
The time interval of query result interface is called to be less than 10s.In other words, at inquiry initial stage, predetermined time interval is smaller, in this way can be with
Ensure submitting in a period of time after data, if result exports, result can be inquired in time.
In a concrete application scene, the m is equal to n, i.e., the increasing degree of each predetermined time interval is equal to just
The predetermined time interval of beginning, such as initial predetermined time interval are 5s, then predetermined time interval next time is 5+5=
10s, then predetermined time interval next time are 10+5=15s, and so on, it obtains between the updated predetermined time each time
Every.
In another concrete application scene, the m is not equal to n, i.e., the increasing degree of each predetermined time interval is not
Equal to initial predetermined time interval, such as initial predetermined time interval is 5s, and predetermined time interval next time is 5+3=
8s, then predetermined time interval next time are 8+3=11s, and so on, obtain updated predetermined time interval each time.
In this step, the increasing degree of predetermined time interval is fixed, and forms the situation of change of a gradient, this
Sample may insure to inquire in time as a result, also avoid too many invalid inquiry operation simultaneously, improve search efficiency.This step is base
In within the first predetermined time to the second predetermined time, the probability for exporting result is higher, so not will increase dramatically described
Predetermined time interval, but the increase predetermined time interval step by step, to avoid the time of result is inquired than output
As a result evening time is too many.
The increasing degree of predetermined time interval determines the size of predetermined time interval next time, so increasing degree is also determined
The polling interval within the first predetermined time to the second predetermined time is determined.The increasing degree due to be fixed setting,
So its occurrence is particularly important.For the method for determination of the increasing degree m of predetermined time interval, can be predetermined according to first
Time determines to the length of time of the second predetermined time, if the length of the first predetermined time to the second predetermined time are longer,
So m is settable larger, if the length of the first predetermined time to the second predetermined time are smaller, then m is settable smaller, i.e., always
Principle be to make to be maintained at a reasonable level in the first predetermined time to the inquiry times that the second predetermined time carried out every time, this
Be because the second predetermined time be (aforementioned second probability is by the first determine the probability) determined based on the first predetermined time,
Second predetermined time was possible to longer, did not represent the probability meeting average mark that result can be inquired in so long time range
Cloth.The embodiment of the present invention reduces invalid inquiry, can control for the first predetermined time to the second pre- timing to save server resource
Between between the inquiry times that are carried out keep within a preset range.
If S202, current time are more than the second predetermined time range, the predetermined time interval is set and is increased every time
In addition one times of a predetermined time interval.
The purpose of above-mentioned steps was specifically limited the case where current time is more than the second predetermined time range, that is, was existed
Under above situation, the increasing degree of predetermined time interval constantly increases, and with the increase of call number, increasing degree is at double
Increase.Such as when current time was more than the second predetermined time, if its predetermined time interval is n, then this is pre- in past n
It fixes time behind interval, will do it and call query result interface to carry out result queries next time and do not inquired yet as a result, at this time
Predetermined time interval will be updated to n*2=2n, wherein the n is the increasing degree of predetermined time interval.So in the past
After this predetermined time interval of 2n, it will do it and call query result interface to carry out result queries next time and do not inquire knot yet
Fruit, predetermined time interval will be updated to 2n*2=4n at this time, wherein the 2n is the increasing degree of predetermined time time interval.
So after this predetermined time interval of past 4n, will do it next time call query result interface carry out result queries and
It is not inquired yet as a result, predetermined time interval will be updated to 4n*2=8n at this time, wherein the 4n is between time predetermined time
Every increasing degree.In this way, and so on, in the case where current time was more than the second predetermined time, inquiry is called each time
As a result interface can all update predetermined time interval simultaneously, will look into next time according to the predetermined time interval updated to be called
Ask result interface.Finally, until inquiring result.
From the above it can be seen that the increasing degree of predetermined time interval is multiplied every time, it is for the first time n, is for the second time
2n is for the third time 4n, and the 4th time is 8n ....With the increase of call number, behind predetermined time interval increasing degree at
Increase again, so the time interval of back calling query result interface is huge relative to initial time interval, so
After current time was more than the second predetermined time, the frequency of calling substantially reduces, and the interval of calling is significantly increased, in the unit time
Call number will be greatly decreased, so invalid inquiry operation is greatly reduced.This step is to be based in current time being more than second
After predetermined time range, the time for exporting result is uncertain too high, so need to be significantly increased the predetermined time interval, without
It is the increase predetermined time interval step by step, to waste excessive inquiry operation.
In a concrete application scene, initial predetermined time interval is 60s, then predetermined time interval next time
Predetermined time interval for 60*2=120s, then next time is 120*2=240s, and so on, it obtains updated each time
Predetermined time interval.
Control in the embodiment of the present invention, when calling query result interface to carry out result queries, to predetermined time interval
Strategy is optimized, and can slowly reduce calling frequency early period by the calling query result interface of fixed calling frequency, mid-term
Rate, later period can substantially reduce calling frequency, to allow control strategy more to meet true inquiry scene, both according to the variation of time
It can inquire in time and occupy server resource and bandwidth as a result, be avoided that and frequently call again, promote search efficiency.
Further, include: before calling query result interface to carry out result queries
Judge that whether the required equipment used is online when query result interface being called to carry out result queries, calls if online
Query result interface carries out result queries, terminates result queries if not online.
Some interfaces supplier needs to be exported using corresponding equipment as a result, example when carrying out offer interface service
If nowadays inquired the current setting temperature of intelligent air condition, if intelligent air condition is not online, it is clear that can not inquire corresponding
Temperature is set, it is possible to first judge that equipment is online, call query result interface to carry out result if equipment on-line and look into
It askes, terminates result queries if not online, it in this way can be to avoid invalid inquiry, because equipment is not that will not export to appoint online
What result, so result queries can be terminated at this time.
Further, described to terminate result queries if not online and include:
The not online duration of detection device terminates result queries if the not online duration of equipment is more than time threshold.
Equipment is only interim not online in some cases, i.e., only ought for the previous period in it is not online, in a period of time
Afterwards, equipment may be online, and in other words, the equipment not online time is longer, and online probability is also lower in that subsequent a period of time,
So the not online duration of equipment is more than time threshold if preferably detecting in the embodiment of the present invention, terminates result and look into
It askes.The time threshold can be 5 minutes~15 minutes, such as 10 minutes, that is to say, that the not online duration of equipment is more than 10
Minute, just terminate result queries.
Further, if do not inquire as a result, if by result queries when required request data keep in into caching, confession is next
It is used when secondary result queries.Because when carrying out result queries, required request data is essentially identical every time, it is possible to first
Secondary progress result queries and when not inquiring result, first time is subjected to request data used in result queries and is kept in caching
In, i.e. redis caching only needs directly to read the request data from caching i.e. in this way when carrying out result queries next time
Can, read or write speed can be improved in this way, and then accelerate search efficiency.
The case where even for multiple data are submitted, generally only needs one since desired request data is smaller in inquiry
Two fields, so for repeatedly inquiring Different Results, it still can be temporary in the buffer by various request datas, and be unlikely to
Overabundance of data in caching.
Further, if inquire as a result, if corresponding request data will delete in caching.Specifically, once being looked into any
When asking operation, if inquire as a result, if can directly will corresponding request data deletion in caching because after inquiring result,
Querying flow terminates, and does not need to reuse corresponding request data at this time, so directly deleting.
In some circumstances, it needs to complete to log in and just can be carried out inquiry, so when detecting the request that user logs in, then
It is primary to wake up inquiry, i.e. call result query interface is inquired, can be according to the side of above-described embodiment after logining successfully
Formula is inquired.
Fig. 2 is referred to, Fig. 2 is a kind of structural schematic diagram of asynchronous query device provided by the embodiment of the present invention;
The apparatus may include:
First enquiry module 201 recalls query result interface after calling submission data-interface to carry out data submission
Carry out result queries;
Second enquiry module 202, for if do not inquire as a result, if at predetermined time intervals interval call one query result
Interface carries out result queries;
Wherein, the control strategy of the predetermined time interval is as follows: if current time within the first predetermined time,
It is fixed value that the predetermined time interval, which is arranged,;If current time is more than the first predetermined time range, setting is looked into based on calling
The increase of the number of result interface is ask, and increases the predetermined time interval.
Further, which can also include:
Judgment module, when for judging that query result interface is called to carry out result queries the required equipment used whether
Line calls query result interface to carry out result queries if online, if not terminating result queries online.
Further, described to terminate result queries if not online and include:
The not online duration of detection device terminates result queries if the not online duration of equipment is more than time threshold.
Further, the initial value of the predetermined time is less than 10s.
Further, the increase of the setting based on the number for calling query result interface, and increase between the predetermined time
Every including:
If within the first predetermined time to the second predetermined time, it is every that the predetermined time interval is arranged in current time
Secondary increased amplitude is identical;
If current time is more than the second predetermined time range, the predetermined time interval is set and increases upper one every time
One times of predetermined time interval.
Further, if do not inquire as a result, if by result queries when required request data keep in into caching, confession is next
It is used when secondary result queries.
Further, if inquire as a result, if corresponding request data will delete in caching.
Since the embodiment of device part is corresponded to each other with the embodiment of method part, the embodiment of device part is asked
Referring to the description of the embodiment of method part, wouldn't repeat here.
The present invention also provides a kind of computer readable storage mediums, have computer program thereon, the computer program
It is performed the method provided by above-described embodiment that may be implemented.The storage medium may include: USB flash disk, mobile hard disk, read-only deposit
Reservoir (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or
The various media that can store program code such as CD.
The present invention also provides a kind of computer equipments, may include memory and processor, have in the memory
Computer program when the processor calls the computer program in the memory, may be implemented above-described embodiment and be provided
Method.Certain computer equipment can also include various network interfaces, the components such as power supply.
Each embodiment is described in a progressive manner in specification, the highlights of each of the examples are with other realities
The difference of example is applied, the same or similar parts in each embodiment may refer to each other.For device disclosed in embodiment
Speech, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part illustration
.It should be pointed out that for those skilled in the art, without departing from the principle of the present invention, also
Can be with several improvements and modifications are made to the present invention, these improvement and modification also fall into the protection scope of the claims in the present invention
It is interior.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that
A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.Under the situation not limited more, the element limited by sentence "including a ..." is not arranged
Except there is also other identical elements in the process, method, article or apparatus that includes the element.
Claims (10)
1. a kind of asynchronous query method, which is characterized in that comprising steps of
It calls after submitting data-interface to carry out data submission, recalls query result interface and carry out result queries;
If do not inquire as a result, if at predetermined time intervals interval call one query result interface carry out result queries;
Wherein, the control strategy of the predetermined time interval is as follows: if current time is arranged within the first predetermined time
The predetermined time interval is fixed value;If current time is more than the first predetermined time range, setting is based on calling inquiry knot
The increase of the number of fruit interface, and increase the predetermined time interval.
2. asynchronous query method according to claim 1, which is characterized in that query result interface is being called to carry out result queries
Include: before
Judge that whether the required equipment used is online when query result interface being called to carry out result queries, calls inquiry if online
As a result interface carries out result queries, terminates result queries if not online.
3. asynchronous query method according to claim 2, which is characterized in that described to terminate result queries packet if not online
It includes:
The not online duration of detection device terminates result queries if the not online duration of equipment is more than time threshold.
4. asynchronous query method according to claim 1, which is characterized in that the initial value of the predetermined time interval is less than
10s。
5. asynchronous query method according to claim 1, which is characterized in that the setting is based on calling query result interface
The increase of number, and increase the predetermined time interval and include:
If current time within the first predetermined time to the second predetermined time, is arranged the predetermined time interval and increases every time
The amplitude added is identical;
If current time be more than the second predetermined time range, be arranged the predetermined time interval increase every time upper one make a reservation for
One times of time interval.
6. asynchronous query method according to claim 1, which is characterized in that if do not inquire as a result, if by result queries when
Required request data is kept in into caching, for using when result queries next time.
7. asynchronous query method according to claim 6, which is characterized in that if inquire as a result, if will caching in it is corresponding
Request data is deleted.
8. a kind of asynchronous query device characterized by comprising
First enquiry module recalls query result interface and is tied after calling submission data-interface to carry out data submission
Fruit inquiry;
Second enquiry module, for if do not inquire as a result, if at predetermined time intervals interval call one query result interface into
Row result queries;
Wherein, the control strategy of the predetermined time interval is as follows: if current time is arranged within the first predetermined time
The predetermined time interval is fixed value;If current time is more than the first predetermined time range, setting is based on calling inquiry knot
The increase of the number of fruit interface, and increase the predetermined time interval.
9. a kind of computer equipment, which is characterized in that including memory, processor and be stored on the memory and can be in institute
The computer program run on processor is stated, the processor realizes such as claim 1 to 7 times when executing the computer program
Asynchronous query method described in one.
10. a kind of computer readable storage medium, which is characterized in that be stored with computer on the computer readable storage medium
Program realizes the asynchronous query method as described in any one of claim 1 to 7 when the computer program is executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910777851.XA CN110489444B (en) | 2019-08-22 | 2019-08-22 | Asynchronous query method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910777851.XA CN110489444B (en) | 2019-08-22 | 2019-08-22 | Asynchronous query method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110489444A true CN110489444A (en) | 2019-11-22 |
CN110489444B CN110489444B (en) | 2023-06-13 |
Family
ID=68552944
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910777851.XA Active CN110489444B (en) | 2019-08-22 | 2019-08-22 | Asynchronous query method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110489444B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115314530A (en) * | 2022-06-30 | 2022-11-08 | 中国第一汽车股份有限公司 | Information processing method and device and vehicle |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105306618A (en) * | 2015-09-25 | 2016-02-03 | 互联网域名系统北京市工程研究中心有限公司 | Method and device for automatically defending DNS from analyzing and requesting DDoS attacks |
CN107515571A (en) * | 2017-07-12 | 2017-12-26 | 广东美的制冷设备有限公司 | Monitoring Data acquisition method and device, system |
CN107943828A (en) * | 2017-10-18 | 2018-04-20 | 深圳市牛鼎丰科技有限公司 | Service condition querying method, device, computer equipment and storage medium |
CN109727010A (en) * | 2018-05-14 | 2019-05-07 | 网联清算有限公司 | Service inquiry method, apparatus, computer equipment and storage medium |
CN110019261A (en) * | 2017-09-30 | 2019-07-16 | 北京国双科技有限公司 | Data query method and apparatus |
-
2019
- 2019-08-22 CN CN201910777851.XA patent/CN110489444B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105306618A (en) * | 2015-09-25 | 2016-02-03 | 互联网域名系统北京市工程研究中心有限公司 | Method and device for automatically defending DNS from analyzing and requesting DDoS attacks |
CN107515571A (en) * | 2017-07-12 | 2017-12-26 | 广东美的制冷设备有限公司 | Monitoring Data acquisition method and device, system |
CN110019261A (en) * | 2017-09-30 | 2019-07-16 | 北京国双科技有限公司 | Data query method and apparatus |
CN107943828A (en) * | 2017-10-18 | 2018-04-20 | 深圳市牛鼎丰科技有限公司 | Service condition querying method, device, computer equipment and storage medium |
CN109727010A (en) * | 2018-05-14 | 2019-05-07 | 网联清算有限公司 | Service inquiry method, apparatus, computer equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115314530A (en) * | 2022-06-30 | 2022-11-08 | 中国第一汽车股份有限公司 | Information processing method and device and vehicle |
CN115314530B (en) * | 2022-06-30 | 2024-01-05 | 中国第一汽车股份有限公司 | Information processing method and device and vehicle |
Also Published As
Publication number | Publication date |
---|---|
CN110489444B (en) | 2023-06-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP2019508795A (en) | Resource allocation for computer processing | |
CN106648904A (en) | Self-adaptive rate control method for stream data processing | |
CN106537287A (en) | Methods and apparatus to estimate power performance of a job that runs on multiple nodes of a distributed computer system | |
CN107257363B (en) | Method and system for responding request of request terminal | |
CN103606098A (en) | Network real-time bidding control method and device | |
CN102821113A (en) | Cache method and system | |
US20160358208A1 (en) | Method, device, system for displaying media data | |
CN112559182A (en) | Resource allocation method, device, equipment and storage medium | |
CN1968527A (en) | Method for intelligent connection between mobile phone client and server | |
CN110489444A (en) | A kind of asynchronous query method, apparatus, computer equipment and storage medium | |
WO2022188575A1 (en) | Hyperparameter tuning method and apparatus, and storage medium | |
US20160277542A1 (en) | Data stream load balancing utilizing multiple sets of servers | |
CN113626199B (en) | Management method and device of idle cloud computing resources, electronic equipment and storage medium | |
CN105824691A (en) | Method and device for dynamically regulating threads | |
CN112965823A (en) | Call request control method and device, electronic equipment and storage medium | |
CN113312553B (en) | User tag determining method and device | |
CN110753101B (en) | Low-energy-consumption computing node selection and computing task allocation method in edge computing | |
CN110347477B (en) | Service self-adaptive deployment method and device in cloud environment | |
CN116661960A (en) | Batch task processing method, device, equipment and storage medium | |
CN109756372B (en) | Elastic expansion method and device for telecommunication charging system | |
CN107911484B (en) | Message processing method and device | |
CN112540836B (en) | Service scheduling management method and system | |
CN116467344A (en) | Data processing method, apparatus, device, storage medium and computer program product | |
CN113259439B (en) | Key value scheduling method based on receiving end drive | |
CN103078766A (en) | Network flow rate audit method, device and network equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |