CN109918191A - A kind of method and apparatus of the anti-frequency of service request - Google Patents

A kind of method and apparatus of the anti-frequency of service request Download PDF

Info

Publication number
CN109918191A
CN109918191A CN201711329279.8A CN201711329279A CN109918191A CN 109918191 A CN109918191 A CN 109918191A CN 201711329279 A CN201711329279 A CN 201711329279A CN 109918191 A CN109918191 A CN 109918191A
Authority
CN
China
Prior art keywords
return value
cache key
frequency
frequency number
code
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
Application number
CN201711329279.8A
Other languages
Chinese (zh)
Other versions
CN109918191B (en
Inventor
董焕强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711329279.8A priority Critical patent/CN109918191B/en
Publication of CN109918191A publication Critical patent/CN109918191A/en
Application granted granted Critical
Publication of CN109918191B publication Critical patent/CN109918191B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Storage Device Security (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention discloses a kind of method and apparatus of the anti-frequency of service request, are related to field of computer technology.One specific embodiment of this method includes: to obtain the corresponding cache key of current business code, updates the value of cache key to obtain return value;Return value is compared with anti-frequency number, when determining that return value is greater than anti-frequency number, does not execute service code.Which overcomes heavy workload caused by causing anti-frequency to fail due to exist in the prior art because while handling multiple business, repeatedly writing rate height and there is the low problem of the security reliabilities such as network duration, and then reach the technical effect for reducing anti-frequency failure and reducing workload, be conducive to improve program development efficiency, reduce the workload of programmer.

Description

A kind of method and apparatus of the anti-frequency of service request
Technical field
The present invention relates to field of computer technology more particularly to a kind of method and apparatus of the anti-frequency of service request.
Background technique
With the development of internet, more and more users pass through shopping at network, make friends, obtain information, and give internet The supplier of service brings bigger pressure, in order to guarantee that service can bear certain user's amount of access and concurrency, Service is general by the way of distributed deployment, i.e., by same service arrangement to n platform server, this n platform server is right simultaneously Outer offer service.But due to having no communication between this n platform server, it is easy to by malicious attacker attack (such as: DDoS is attacked It hits);If user normally requests to repeat to send and by different server process simultaneously, it is easy to operational confusion occur Or to cause server to occur a large amount of abnormal, so as to cause resource waste and jeopardize the availability of service.In order to guarantee to service Stablize us the access times to user in specific time needed to be limited, i.e., anti-frequency.
The mode of the anti-frequency of distribution of current main-stream be using the SET order in caching Redis in conjunction with GET command come reality Existing, Redis is a high performance memory database, stores key-value pair data.Redis uses one process single thread mode, It can guarantee concurrent sequence, all operations are directly handled by memory, ultrahigh in efficiency, and distributed type assemblies is supported to configure.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery:
There is because while causing due to handling multiple business anti-frequency failure when taking anti-frequency measure in the prior art, repeat to compile It writes heavy workload caused by rate height and the low problem of the security reliabilities such as network duration occurs.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and apparatus of anti-frequency of service request, by service code In preset and explain configuration information, then according to return value and explain the mode that compares of configuration information, effectively reduce anti-frequency The problem of failure, while reducing workload.
To achieve the above object, according to an aspect of an embodiment of the present invention, a kind of side of anti-frequency of service request is provided Method.
A kind of method of the anti-frequency of service request of the embodiment of the present invention, is preset with note configuration information in service code, Explaining configuration information includes anti-frequency number, this method comprises: obtaining the corresponding cache key of current business code, updates cache key Value is to obtain return value;Return value is compared with anti-frequency number, when determining that return value is greater than anti-frequency number, does not execute business Code.
Preferably, explaining configuration information in embodiments of the present invention further includes cache key prefix, obtains current business The step of code corresponding cache key includes: that the unique identification of the cache key prefix and user that will acquire is spliced, with To cache key, wherein the unique identification of user is the unique identification of the user of current business code.
Preferably, it is also wrapped before the step of being compared return value with anti-frequency number in embodiments of the present invention It includes: judging the size of return value, if return value is equal to 1, directly execute service code;If return value is greater than 1, executing will be returned Return the step of value is compared with anti-frequency number.
Preferably, when determining that return value is greater than anti-frequency number in embodiments of the present invention, judge the effective of cache key Whether the phase is permanent;If permanent, then throw exception;If not permanent, then number of dishing out transfinites exception.
Preferably, it in embodiments of the present invention when throw exception, deletes cache key and executes service code.
Preferably, it is realized in embodiments of the present invention by being configured towards tangent plane programming frame Spring AOP.
To achieve the above object, according to another aspect of the present invention, a kind of device of anti-frequency of service request is provided.
A kind of device of the anti-frequency of service request of the embodiment of the present invention, is preset with note configuration information in service code, Explaining configuration information includes anti-frequency number, which includes: acquisition module, for obtaining the corresponding caching of current business code Key updates the value of cache key to obtain return value;Processing module, for return value to be compared with anti-frequency number, determination is returned When returning value greater than anti-frequency number, service code is not executed.
Preferably, explaining configuration information in embodiments of the present invention further includes cache key prefix, obtains module and also uses In: the unique identification of the cache key prefix and user that will acquire is spliced, to obtain cache key, wherein user's is unique Mark is the unique identification of the user of current business code.
Preferably, in embodiments of the present invention further include judgment module, be used for: judging the size of return value, if returning It returns value and is equal to 1, then directly execute service code;If return value is greater than 1, what return value was compared by execution with anti-frequency number Step.
Preferably, processing module is also used in embodiments of the present invention: when determining that return value is greater than anti-frequency number, being sentenced Whether the validity period of disconnected cache key is permanent;If permanent, then throw exception;If not permanent, then number of dishing out is super Limit is abnormal.
Preferably, it in embodiments of the present invention when throw exception, deletes cache key and executes service code.
Preferably, it is realized in embodiments of the present invention by being configured towards tangent plane programming frame Spring AOP.
To achieve the above object, in accordance with a further aspect of the present invention, a kind of electronic equipment is provided.
The a kind of electronic equipment of the embodiment of the present invention includes: one or more processors;Storage device, for storing one Or multiple programs, when one or more programs are executed by one or more processors, so that one or more processors realize this The method of the anti-frequency of invention service request.
To achieve the above object, in accordance with a further aspect of the present invention, a kind of computer readable storage medium is provided.
A kind of computer readable storage medium of the embodiment of the present invention, is stored thereon with computer program, which is characterized in that The method of the anti-frequency of service request of the present invention is realized when program is executed by processor.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that because using adding in service code Configuration information is explained, and using configuration information is explained come the technological means of anti-frequency, is existed in the prior art so overcoming because same When handle multiple business and lead to the failure of anti-frequency, repeat to write rate height caused by heavy workload and there is network duration etc. The low problem of security reliability, and then reach the technical effect for reducing anti-frequency failure and reducing workload, be conducive to improve journey Sequence development efficiency reduces the workload of programmer.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment With explanation.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.In the accompanying drawings:
Fig. 1 is a kind of schematic diagram of the main flow of the method for the anti-frequency of service request according to an embodiment of the present invention;
Fig. 2 is the flow diagram of the method according to embodiments of the present invention for implementing the anti-frequency of service request;
Fig. 3 is a kind of schematic diagram of the main modular of the device of the anti-frequency of service request according to an embodiment of the present invention;
Fig. 4 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Fig. 5 is adapted for the structural representation of the computer system for the terminal device or server of realizing the embodiment of the present invention Figure.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
Fig. 1 is a kind of schematic diagram of the main flow of the method for the anti-frequency of service request according to an embodiment of the present invention, such as Fig. 1 Shown, a kind of method of the anti-frequency of service request of the embodiment of the present invention mainly includes the following steps:
Step S101: the corresponding cache key of current business code is obtained, updates the value of cache key to obtain return value.Pass through It is preset in service code and explains configuration information, and carry out anti-frequency using configuration information is explained in subsequent treatment process, To reach technical effect of the invention, overcomes and exist in the prior art because while handling multiple business due to anti-frequency is caused to lose Effect repeats to write heavy workload caused by rate height and the low problem of the security reliabilities such as network duration occurs.It will caching The mode that the value+1 of key is handled can be executed using common INCR order.It should be noted that updating the side of the value of cache key Formula can be the mode for updating the value itself of cache key, for example, obtaining after being handled the value+1 of cache key using INCR order Return value.It should be pointed out that the value of the cache key in the application is the numerical value returned after handling service code, Illustrate that the service code is specifically which time is handled;Anti- frequency is the stabilization in order to guarantee service, to need to user Access times in specific time make restriction scheme.
In embodiments of the present invention, explaining configuration information further includes cache key prefix, obtains current business code pair The step of cache key answered includes: that the unique identification of the cache key prefix and user that will acquire is spliced, to be cached Key, wherein the unique identification of user is the unique identification of the user of current business code.The unique identification of user can be using use ID, the IMS at family and the combination of other forms.
Step S102: return value is compared with anti-frequency number, when determining that return value is greater than anti-frequency number, does not execute industry Business code.By comparing, it is abnormal to determine that current service code whether there is, if result is that return value is greater than anti-frequency number, It determines that current service code is abnormal, does not execute the service code;If return value is less than or equal to anti-frequency number, continue to execute described Service code (namely continuing to carry out the service code abnormal judgement).
In embodiments of the present invention, explaining configuration information further includes the cache key time-to-live, by return value and anti- Before the step of frequency number is compared further include: judge the size of return value, if return value is equal to 1, survived according to cache key The validity period of cache key is arranged in time, executes service code;If return value is greater than 1, execute by return value and anti-frequency number into It the step of row compares, is compared.
Specifically, after determining that return value is greater than anti-frequency number, it is also necessary to which whether the validity period for judging cache key is forever Long property;If permanent, then throw exception;If not permanent, then number of dishing out transfinites exception.There is message by cache key To facilitate subsequent be further processed to classifying extremely.
In an embodiment of the present invention, specific processing mode is, when throw exception, to delete cache key and execute business Code.Certainly, it transfinites exception if number, then recycle time transfinites prompt information.It should be noted that working as in the present invention, throws When abnormal out, delete cache key and simultaneously execute service code, be only a kind of example, it, can also be with when network timeout or when mistake occurs It deletes cache key and executes service code.
In an embodiment of the present invention, the process of above-mentioned judgement and comparison is by towards tangent plane programming frame Spring AOP configuration is realized.It is above-mentioned service code is analyzed and is judged after, just will do it execution step.
Fig. 2 is the flow diagram of the method according to embodiments of the present invention for implementing the anti-frequency of service request, as shown in Fig. 2, Before starting to illustrate embodiments of the present invention, description below first is made to noun according to the present invention:
Redis: one high performance key-value database memory-based, it is ensured that complications are issued orders execution Succession.
INCR order in Redis: the corresponding value of key is increased into the value returned after increasing one together, if key is not present, key Value can first be initialized to 0, then execute again INCR operation.
EXPIRE order in Redis: the expired time for set key.
DEL order in Redis: for deleting already present key.
TTL order in Redis: the remaining expired time of return key in seconds.
SET order in Redis: for specified key setting value and its expired time.
GET command in Redis: for obtaining the value of assignment key.
Spring: being an Open Framework, and Spring is the Java Development Framework of the lightweight risen in 2003, It is created by Rod Johnson.In simple terms, Spring is JavaSE/EEfullstack (one-stop) lightweight of a layering Open Framework.
AOP:Aspect Oriented Programming, towards tangent plane programming.The purpose that AOP is mainly realized is to be directed to Section in business procession extracts, and what it was faced is some step or the stage in treatment process, to be patrolled During volume between each section lower coupling isolation effect.
It explains: being also metadata.A kind of other explanation of code level.It is JDK1.5 and the spy that later version introduces Property, and class, interface, to enumerate be in the same level.It can be stated in packet, class, field, method, local variable, method parameter Deng before, for being illustrated to these elements, annotation.
DDOS: distributed denial of service (Distributed Denial of Service) attack refers to by means of client/clothes It is engaged in device technology, multiple computers is joined together as Attack Platform, ddos attack is started to one or more targets, from forming The power of Denial of Service attack is improved again.
Following two step is specifically divided by the process that database Redis is judged in the prior art:
One, it into after the service code method of execution, is obtained in Redis by the GET command in Redis and corresponds to this industry Value corresponding to the key of business gives an initial value 0 if not having corresponding value in Redis, then will by SET order This value is stored in Redis, while the expired time of this key is arranged.
Two, judge whether the value that this corresponding service key is obtained in previous step is greater than the maximum number of times of setting, if it is greater than then Service code is not executed and directly returns to miscue, and the value+1 that otherwise will be obtained in previous step will this corresponding industry by SET order It is engaged in the value deposit Redis of key, continues to execute service code.
In the application, after certain server receives user's request in Distributed Services, judging request first will be held Whether capable service code method has note configuration information, can be directly by service code if not explaining configuration information It is sent to execution module, executes the service code.
If before executing service code, user's request is intercepted with configuration information is explained, prevent into of the invention Frequency processor module logic, to analyze the service code.
Further, it obtains and explains configuration information (cache key prefix information, cache key time-to-live information, anti-frequency number Information), cache key prefix information and the unique identification of the user currently logged in are spliced to generate the caching in database Redis Key, and execute the INCR order of database Redis (INCR order is every, which to be executed, primary can all add the corresponding value of cache key after 1 Return again to), obtain return value.Judge whether return value is 1 (namely judging whether current return value is more than or equal to 1), Then prove that the cache key is not present before the request if return value is 1, the EXPIRE order setting executed in Redis at this time should The validity period of cache key is the cache key time-to-live explained in configuration information;It proves if return value is not 1 in request The preceding cache key has existed and also not out of date, continues to judge whether return value is greater than the anti-frequency number explained in configuration information Information lets pass this request if return value is less than or equal to anti-frequency number information, if return value is believed greater than anti-frequency number Breath, then execute the TTL order of database Redis, obtain return value, then further judge whether the validity period of the cache key is forever (the judge whether return value is -1 (- 1 represent permanent) of long property), be permanently represent program occur exception directly dish out it is different Often;Cache key is not the cache key time-to-live permanently then proved in anti-frequency control normal program operation and current business code Already exceed preset anti-frequency number information, number of dishing out transfinites exception.That then collects that anti-frequency processor module dishes out is all Whether exception information (i.e. comprising above-mentioned throw exception, number of dishing out transfinite exception and system exception), judge Exception Type It transfinites exception for number, if it (may be that the above-mentioned caching key information analyzed is wrong that Exception Type, which is not that number transfinites abnormal, Exception accidentally, it is also possible to network timeout or system exception) then prove that graunch occurs for anti-frequency programmed logic, execute Redis In DEL order the cache key is deleted, continue to execute service code, i.e., mistake occur in anti-frequency component or in the case of exception Still ensure that service is available;Service code is not executed if Exception Type transfinites exception for number and returns to requester requests time Count the prompt information that transfinites.
The method of the anti-frequency of service request according to an embodiment of the present invention can be seen that because using adding in service code Configuration information is explained, and using configuration information is explained come the technological means of anti-frequency, is existed in the prior art so overcoming because same When handle multiple business and lead to the failure of anti-frequency, repeat to write rate height caused by heavy workload and there is network duration etc. The low problem of security reliability, and then reach the technical effect for reducing anti-frequency failure and reducing workload, be conducive to improve journey Sequence development efficiency reduces the workload of programmer.The method of the anti-frequency of service request of the invention when in use, in service code Set up defences in advance the note configuration information of frequency, specified in explaining configuration information cache key prefix information, cache key time-to-live information, Anti- frequency number information, it is high-efficient, it is easy to maintain, and absolutely not coupled with service code module.
Fig. 3 is a kind of schematic diagram of the main modular of the device of the anti-frequency of service request according to an embodiment of the present invention, such as Fig. 3 Shown, the device 300 of the anti-frequency of the service code of the embodiment of the present invention, which specifically includes that, obtains module 301 and processing module 302, In:
It obtains module 301 and updates the value of cache key for obtaining the corresponding cache key of current business code to be returned Value;Processing module 302 when determining that return value is greater than anti-frequency number, is not executed for return value to be compared with anti-frequency number Service code.Configuration information is explained by presetting in service code, and using explaining configuration information come the technological means of anti-frequency, And then technical effect of the invention is reached.
Further, explaining configuration information further includes cache key prefix, obtains module and is also used to: the cache key that will acquire Prefix and the unique identification of user are spliced, to obtain cache key, wherein the unique identification of user is current business code The unique identification of user.
In embodiments of the present invention further include judgment module (not shown), be used for: judging the size of return value, If return value is equal to 1, service code is directly executed;If return value is greater than 1, return value and anti-frequency number are compared in execution Compared with the step of.
In addition, processing module is also used to: determine return value be greater than the anti-frequency number when, judge cache key validity period whether be Permanently;If permanent, then throw exception;If not permanent, then number of dishing out transfinites exception.
In embodiments of the present invention when throw exception, deletes cache key and execute service code.
Specifically, being realized in embodiments of the present invention by being configured towards tangent plane programming frame Spring AOP.
From the above, it can be seen that because using the addition note configuration information in service code, and matched using note Confidence breath carrys out the technological means of anti-frequency, exists in the prior art because while handling multiple business so overcoming due to anti-frequency is caused to lose Effect repeats to write heavy workload caused by rate height and the low problem of the security reliabilities such as network duration, Jin Erda occurs To reducing anti-frequency failure and reducing the technical effect of workload, is conducive to improve program development efficiency, reduces the work of programmer It measures.The method of the anti-frequency of service request of the invention when in use, the note configuration information for frequency of setting up defences in advance in service code, It explains and specifies cache key prefix information, cache key time-to-live information, anti-frequency number information in configuration information, it is high-efficient, It is easy to maintain, and absolutely not coupled with service code module.
Fig. 4 is shown can be using the method for the anti-frequency of service request of the embodiment of the present invention or the device of the anti-frequency of service code Exemplary system architecture 400.
As shown in figure 4, system architecture 400 may include terminal device 401,402,403, network 404 and server 405. Network 404 between terminal device 401,402,403 and server 405 to provide the medium of communication link.Network 404 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 401,402,403 and be interacted by network 404 with server 405, to receive or send out Send message etc..Various telecommunication customer end applications, such as the application of shopping class, net can be installed on terminal device 401,402,403 (merely illustrative) such as the application of page browsing device, searching class application, instant messaging tools, mailbox client, social platform softwares.
Terminal device 401,402,403 can be the various electronic equipments with display screen and supported web page browsing, packet Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 405 can be to provide the server of various services, such as utilize terminal device 401,402,403 to user The shopping class website browsed provides the back-stage management server (merely illustrative) supported.Back-stage management server can be to reception To the data such as information query request analyze etc. processing, and by processing result (such as target push information, product letter Breath -- merely illustrative) feed back to terminal device.
It should be noted that the method for the anti-frequency of service request provided by the embodiment of the present invention is generally held by server 405 Row, correspondingly, the device of the anti-frequency of service code is generally positioned in server 405.
It should be understood that the number of terminal device, network and server in Fig. 4 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
Below with reference to Fig. 5, it illustrates the computer systems 500 for the terminal device for being suitable for being used to realize the embodiment of the present invention Structural schematic diagram.Terminal device shown in Fig. 5 is only an example, function to the embodiment of the present invention and should not use model Shroud carrys out any restrictions.
As shown in figure 5, computer system 500 includes central processing unit (CPU) 501, it can be read-only according to being stored in Program in memory (ROM) 502 or be loaded into the program in random access storage device (RAM) 503 from storage section 508 and Execute various movements appropriate and processing.In RAM 503, also it is stored with system 500 and operates required various programs and data. CPU 501, ROM 502 and RAM 503 are connected with each other by bus 504.Input/output (I/O) interface 505 is also connected to always Line 504.
I/O interface 505 is connected to lower component: the importation 506 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 507 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 508 including hard disk etc.; And the communications portion 509 of the network interface card including LAN card, modem etc..Communications portion 509 via such as because The network of spy's net executes communication process.Driver 510 is also connected to I/O interface 505 as needed.Detachable media 511, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 510, in order to read from thereon Computer program be mounted into storage section 508 as needed.
Particularly, disclosed embodiment, the process described above with reference to flow chart may be implemented as counting according to the present invention Calculation machine software program.For example, embodiment disclosed by the invention includes a kind of computer program product comprising be carried on computer Computer program on readable medium, the computer program include the program code for method shown in execution flow chart.? In such embodiment, which can be downloaded and installed from network by communications portion 509, and/or from can Medium 511 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 501, system of the invention is executed The above-mentioned function of middle restriction.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In the present invention, computer readable storage medium can be it is any include or storage journey The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this In invention, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of above-mentioned module, program segment or code include one or more Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical On can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it wants It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction It closes to realize.
Being described in module involved in the embodiment of the present invention can be realized by way of software, can also be by hard The mode of part is realized.Described module also can be set in the processor, for example, can be described as: a kind of processor packet It includes and obtains module and processing module.Wherein, the title of these modules does not constitute the limit to the module itself under certain conditions It is fixed.
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes Obtaining the equipment includes: to obtain the corresponding cache key of current business code, updates the value of cache key to obtain return value;By return value It is compared with anti-frequency number, when determining that return value is greater than anti-frequency number, does not execute service code.
Technical solution according to an embodiment of the present invention, because using the addition note configuration information in service code, and benefit With note configuration information come the technological means of anti-frequency, exists in the prior art because while handling multiple business so overcoming due to lead Heavy workload and occur that the security reliabilities such as network duration are low to ask caused by causing the failure of anti-frequency, repeating to write rate height Topic, and then reach the technical effect for reducing anti-frequency failure and reducing workload, be conducive to improve program development efficiency, reduce journey The workload of sequence person.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention Within.

Claims (14)

1. a kind of method of the anti-frequency of service request, which is characterized in that be preset with note configuration information, the note in service code Solving configuration information includes anti-frequency number, which comprises
The corresponding cache key of current business code is obtained, updates the value of the cache key to obtain return value;
The return value is compared with the anti-frequency number, when determining that the return value is greater than the anti-frequency number, is not held The row service code.
2. being obtained the method according to claim 1, wherein the note configuration information further includes cache key prefix The step of taking current business code corresponding cache key include:
The unique identification of the cache key prefix and user that will acquire is spliced, to obtain cache key, wherein the use The unique identification at family is the unique identification of the user of the current business code.
3. the method according to claim 1, wherein the return value is compared with the anti-frequency number The step of before further include:
Judge the size of the return value, if the return value is equal to 1, directly executes the service code;If the return Value is greater than 1, then executes the step of being compared the return value with the anti-frequency number.
4. the method according to claim 1, wherein sentencing when determining that the return value is greater than the anti-frequency number Whether break validity period of the cache key is permanent;If permanent, then throw exception;If not permanent, then dish out secondary Count the exception that transfinites.
5. according to the method described in claim 4, it is characterized in that, deleting the cache key when the throw exception and holding The row service code.
6. method according to claim 1-5, which is characterized in that by towards tangent plane programming frame Spring AOP Configuration is realized.
7. a kind of device of the anti-frequency of service request, which is characterized in that be preset with note configuration information, the note in service code Solving configuration information includes anti-frequency number, and described device includes:
It obtains module and updates the value of the cache key for obtaining the corresponding cache key of current business code to obtain return value;
It is described anti-to determine that the return value is greater than for the return value to be compared with the anti-frequency number for processing module When frequency number, the service code is not executed.
8. device according to claim 7, which is characterized in that the note configuration information further includes cache key prefix, institute Acquisition module is stated to be also used to:
The unique identification of the cache key prefix and user that will acquire is spliced, to obtain cache key, wherein the use The unique identification at family is the unique identification of the user of the current business code.
9. device according to claim 7, which is characterized in that further include judgment module, be used for:
Judge the size of the return value, if the return value is equal to 1, directly executes the service code;If the return Value is greater than 1, then executes the step of being compared the return value with the anti-frequency number.
10. device according to claim 7, which is characterized in that the processing module is also used to: determining that the return value is big When the anti-frequency number, judge whether the validity period of the cache key is permanent;If permanent, then throw exception;If Be not it is permanent, then number of dishing out transfinites exception.
11. device according to claim 7, which is characterized in that when the throw exception, delete the cache key and hold The row service code.
12. according to the described in any item methods of claim 7-11, which is characterized in that by towards tangent plane programming frame Spring AOP configuration is realized.
13. a kind of electronic equipment characterized by comprising
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real Now such as method as claimed in any one of claims 1 to 6.
14. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor Such as method as claimed in any one of claims 1 to 6 is realized when row.
CN201711329279.8A 2017-12-13 2017-12-13 Method and device for preventing frequency of service request Active CN109918191B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711329279.8A CN109918191B (en) 2017-12-13 2017-12-13 Method and device for preventing frequency of service request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711329279.8A CN109918191B (en) 2017-12-13 2017-12-13 Method and device for preventing frequency of service request

Publications (2)

Publication Number Publication Date
CN109918191A true CN109918191A (en) 2019-06-21
CN109918191B CN109918191B (en) 2021-02-26

Family

ID=66958795

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711329279.8A Active CN109918191B (en) 2017-12-13 2017-12-13 Method and device for preventing frequency of service request

Country Status (1)

Country Link
CN (1) CN109918191B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110661863A (en) * 2019-09-20 2020-01-07 政采云有限公司 Request processing method and device, electronic equipment and storage medium
CN110674168A (en) * 2019-08-29 2020-01-10 北京大米科技有限公司 Cache key abnormity detection method, device, storage medium and terminal
CN113254465A (en) * 2021-05-25 2021-08-13 四川虹魔方网络科技有限公司 Cache final consistency updating method
CN113254464A (en) * 2021-05-19 2021-08-13 北京沃东天骏信息技术有限公司 Data loading method and device
CN114844947A (en) * 2022-04-29 2022-08-02 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453500A (en) * 2016-09-07 2017-02-22 努比亚技术有限公司 Cache generation and control method, cache server and interface server

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453500A (en) * 2016-09-07 2017-02-22 努比亚技术有限公司 Cache generation and control method, cache server and interface server

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
都市烟火: "Redis 实现接口访问频率限制,博客园,https://www.cnblogs.com/duhuo/p/5002319.html", 《REDIS 实现接口访问频率限制》 *
闲情偶寄: "使用Spring注解获取配置文件信息,博客园,https://www.cnblogs.com/Dylansuns/p/7302467.html?utm_medium=referral&utm_source=itdadao", 《使用SPRING注解获取配置文件信息》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674168A (en) * 2019-08-29 2020-01-10 北京大米科技有限公司 Cache key abnormity detection method, device, storage medium and terminal
CN110661863A (en) * 2019-09-20 2020-01-07 政采云有限公司 Request processing method and device, electronic equipment and storage medium
CN113254464A (en) * 2021-05-19 2021-08-13 北京沃东天骏信息技术有限公司 Data loading method and device
CN113254464B (en) * 2021-05-19 2023-12-05 北京沃东天骏信息技术有限公司 Data loading method and device
CN113254465A (en) * 2021-05-25 2021-08-13 四川虹魔方网络科技有限公司 Cache final consistency updating method
CN113254465B (en) * 2021-05-25 2022-11-01 四川虹魔方网络科技有限公司 Cache final consistency updating method
CN114844947A (en) * 2022-04-29 2022-08-02 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium
CN114844947B (en) * 2022-04-29 2024-03-26 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium

Also Published As

Publication number Publication date
CN109918191B (en) 2021-02-26

Similar Documents

Publication Publication Date Title
CN109918191A (en) A kind of method and apparatus of the anti-frequency of service request
CN110019211A (en) The methods, devices and systems of association index
CN108846753B (en) Method and apparatus for processing data
CN111865970B (en) Method and apparatus for implementing interface idempotency
CN107633014A (en) A kind of date storage method and server
CN108897854A (en) A kind of monitoring method and device of overtime task
CN110795315A (en) Method and device for monitoring service
CN110909022A (en) Data query method and device
CN111881329A (en) Account balance management method and system
CN109144992A (en) A kind of method and apparatus of data storage
CN116450622B (en) Method, apparatus, device and computer readable medium for data warehouse entry
CN107657155B (en) Method and device for authenticating user operation authority
CN110782310B (en) Method, device and system for asynchronously acquiring user attribute information from third-party platform
CN110020271A (en) Method and system for cache management
CN109947736A (en) The method and system calculated in real time
CN109002389A (en) The method and apparatus of page automatic test
WO2022171190A1 (en) Fixed execution sequence transaction method, and apparatus
CN110493291A (en) A kind of method and apparatus handling HTTP request
CN111865576B (en) Method and device for synchronizing URL classification data
CN109688174A (en) A kind of virtual service implementation method and device based on more agents service
CN109144991A (en) Dynamic divides method, apparatus, electronic equipment and the computer of table can storage medium
CN113296829A (en) Method, device, equipment and computer readable medium for processing service
CN113779122A (en) Method and apparatus for exporting data
CN113495747B (en) Gray scale release method and device
CN109087097A (en) A kind of method and apparatus updating the same mark of chain code

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