CN112256776B - Form repeated submission detection method and device, computer equipment and storage medium - Google Patents

Form repeated submission detection method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112256776B
CN112256776B CN202011109864.9A CN202011109864A CN112256776B CN 112256776 B CN112256776 B CN 112256776B CN 202011109864 A CN202011109864 A CN 202011109864A CN 112256776 B CN112256776 B CN 112256776B
Authority
CN
China
Prior art keywords
writing
storage space
shared storage
submission
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011109864.9A
Other languages
Chinese (zh)
Other versions
CN112256776A (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.)
Wuhan Yuexuebang Network Technology Co Ltd
Original Assignee
Wuhan Yuexuebang Network 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 Wuhan Yuexuebang Network Technology Co Ltd filed Critical Wuhan Yuexuebang Network Technology Co Ltd
Priority to CN202011109864.9A priority Critical patent/CN112256776B/en
Publication of CN112256776A publication Critical patent/CN112256776A/en
Application granted granted Critical
Publication of CN112256776B publication Critical patent/CN112256776B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a method, a device, computer equipment and a storage medium for detecting repeated submission of a form, wherein the method comprises the following steps: when a form submission request is received, generating a form identifier according to form parameters carried in the form submission request, and writing the form identifier into a shared storage space; if the writing of the form identifier into the shared storage space within the preset duration is successful, judging whether a form corresponding to the form identifier exists in a database or not; and writing the form into the database under the condition that the form does not exist in the database. Compared with a front-end anti-repeat strategy, the embodiment of the disclosure is safer, meets the high-concurrency request scene, and can solve the problem of repeated submission of a distributed system.

Description

Form repeated submission detection method and device, computer equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for detecting repeated submission of a form, a computer device, and a storage medium.
Background
In the existing internet application, when a user sends a data submission request to a server through a client, data submission operation on the client is usually triggered by clicking a data submission button, but if a network delays or fails in the process of clicking the button, the client is stuck and the like, the user cannot judge whether the data submission operation is successful, and at the moment, the user mistakenly thinks that the data is not successfully submitted and selects to submit the data again through the button, so that the form is repeatedly submitted.
At present, technologies for preventing form repeated submission can be roughly divided into two categories, one category is that a client technology is utilized to prevent form repeated submission; the other type is to use the server-side technology to prevent the duplication, such as caching submitted data and comparing tokens. The form resubmission prevention at the client side is realized by using a resubmission prevention function designed at the front end, and repeated resubmissions caused by multiple clicks or other misoperation of a user can be intercepted, however, the method is defective: the anti-resubmission function is cached in the local browser, lawless persons can tamper with the local browser file by using technical means and repeatedly submit requests to the server, and the form submission safety is reduced. The data submission cache list duplication prevention and the token comparison duplication prevention belong to a server-side duplication prevention technology, and the former has the defects that the time complexity of list matching is increased linearly along with the increase of the length of a list, and the matching efficiency of data reaching a certain scale is lowered; the token comparison is to prevent the client side from requesting the token from the server side, and the client side submits the form submission request after taking the token, so that the response speed of the browser is theoretically delayed, and the form submission efficiency is reduced.
Disclosure of Invention
The embodiment of the disclosure at least provides a form repeated submission detection method, a form repeated submission detection device, computer equipment and a storage medium, which are used for improving the form submission safety and the form submission efficiency on the premise of preventing the form repeated submission.
In a first aspect, an embodiment of the present disclosure provides a form repeat submission detection method, including:
when a form submission request is received, generating a form identifier according to form parameters carried in the form submission request, and writing the form identifier into a shared storage space;
if the writing of the form identifier into the shared storage space within the preset duration is successful, judging whether a form corresponding to the form identifier exists in a database or not;
and writing the form into the database under the condition that the form does not exist in the database.
In a possible implementation manner, while writing the form identifier into the shared storage space, the method further includes:
recording a first writing time; and
writing a form identifier into the shared storage space according to the following procedures within a preset time length:
writing form identifications into the shared storage space according to a preset time interval;
and recording a second writing time while writing the form identifier into the shared storage space each time until the writing is successful or the time interval between the second writing time and the first writing time is longer than the preset time.
In a possible implementation manner, whether the writing of the form identifier to the shared storage space is successful is determined according to the following process:
after writing a form identifier into the shared storage space each time, receiving a feedback message of the shared storage space;
if the feedback message is a write-in success message, determining that the writing of the form identifier into the shared storage space is successful;
and if the feedback message is a write failure message, determining that the writing of the form identifier into the shared storage space fails.
In one possible implementation, the form identification includes a key-value pair consisting of a primary key and a key value, and the shared storage space includes a remote dictionary service Redis database; and
judging whether a form corresponding to the form identifier exists in a database, specifically comprising:
and judging whether a corresponding form exists in the database or not according to the primary key.
In one possible embodiment, the method further comprises:
deleting the form identification from the shared storage space under the condition that the form exists in the database;
and returning a response message of failed submission aiming at the form submission request.
In a possible implementation, after writing the form into the database, the method further includes:
deleting the form identification from the shared memory space; and
under the condition that the form is successfully written into the database, returning a response message of successful submission aiming at the form submission request; and under the condition that the form fails to be written into the database, returning a response message of failed submission aiming at the form submission request.
In one possible embodiment, the method further comprises:
and under the condition that writing of the form identifier into the shared storage space fails within a preset time length, returning a response message of failed submission aiming at the form submission request.
In a second aspect, an embodiment of the present disclosure further provides a device for detecting repeated submission of a form, including:
the first writing-in module is used for generating a form identifier according to the form parameters carried in the form submission request and writing the form identifier into a shared storage space when the form submission request is received;
the judging module is used for judging whether a form corresponding to the form identifier exists in a database or not if the first writing module successfully writes the form identifier into the shared storage space within a preset time length;
and the second writing module is used for writing the form into the database under the condition that the judging module judges that the form does not exist in the database.
In a possible implementation, the apparatus further comprises a recording module, wherein:
the recording module is used for recording a first writing time while the first writing module writes the form identifier into the shared storage space; recording a second writing time while the first writing module writes the form identifier into the shared storage space each time;
the first writing module is specifically configured to write a form identifier into the shared storage space according to a preset time interval; until the writing is successful or the time interval between the second writing time and the first writing time is greater than the preset time.
In a possible implementation manner, the determining module is specifically configured to determine whether writing of the form identifier to the shared storage space is successful according to the following procedure: after writing a form identifier into the shared storage space each time, receiving a feedback message of the shared storage space; if the feedback message is a write-in success message, determining that the writing of the form identifier into the shared storage space is successful; and if the feedback message is a write failure message, determining that the writing of the form identifier into the shared storage space fails.
In one possible implementation, the form identification includes a key-value pair consisting of a primary key and a key value, and the shared storage space includes a remote dictionary service Redis database; and
the judging module is specifically used for judging whether a corresponding form exists in the database according to the main key.
In a possible embodiment, the apparatus further comprises:
the first deleting module is used for deleting the form identifier from the shared storage space under the condition that the judging module judges that the form exists in the database;
and the first feedback module is used for returning a response message of failed submission aiming at the form submission request.
In one possible implementation, the method further includes:
a second deleting module, configured to delete the form identifier from the shared storage space after writing the form into the database;
the second feedback module is further used for returning a response message of successful submission aiming at the form submission request under the condition that the form is successfully written into the database; and in the case of failure of writing the form into the database, returning a response message of failed submission aiming at the form submission request.
In one possible embodiment, the method further comprises:
and the third feedback module is used for returning a response message of failed submission aiming at the form submission request under the condition that the first writing module fails to write the form identifier into the shared storage space within a preset time length.
In a third aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, this disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.
For the description of the effect of the above form repeat submission detecting apparatus, computer device and storage medium, reference is made to the description of the above form repeat submission detecting method, which is not repeated here.
The method, the device, the computer equipment and the storage medium for detecting form repeated submission provided by the embodiment of the disclosure generate the form identifier according to the form parameter in the form submission request, and store the form identifier in the shared storage space, so that when a user performs the form repeated operation for multiple times, the user can judge whether the form identifier is repeatedly submitted by judging whether the same form identifier exists in the shared storage space, if the writing is successful, the repeated submission operation does not exist, if the writing is failed, the repeated submission exists, and after the writing is successful, the form identifier exists in the database is judged, and if the form identifier does not exist in the database, the form identifier is written into the database and deleted in the shared storage space.
Further, the method for detecting repeated submission of the form provided by the embodiment of the present disclosure may further record a first writing time while writing the form identifier into the shared storage space, write the form identifier into the shared storage space according to a preset time interval within a preset time duration, and record a second writing time while writing the form identifier into the shared storage space each time until the writing is successful or a time interval between the second writing time and the first writing time is greater than the preset time duration, thereby avoiding that the server always attempts to write the form identifier into the shared storage space, and saving resource overhead of the server.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
FIG. 1 is a flow chart illustrating a method for detecting duplicate submission of a form provided by an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating a method for writing to a shared memory space in a method for detecting duplicate submission of a form provided by an embodiment of the present disclosure;
FIG. 3 illustrates a specific implementation process of a form repeat submission detection method provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram illustrating an apparatus for detecting duplicate submission of a form provided by an embodiment of the present disclosure;
fig. 5 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
Furthermore, the terms "first," "second," and the like in the description and in the claims, and in the drawings described above, in the embodiments of the present disclosure are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be implemented in other sequences than those illustrated or described herein.
Reference herein to "a plurality or a number" means two or more. "and/or" describes the association relationship of the associated object, indicating that there may be three relationships, for example, a and/or B, which may indicate: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
Research shows that the technologies for preventing the form from being repeatedly submitted can be roughly divided into two categories, one category is that the client technology is utilized to prevent the form from being repeatedly submitted; the other is that the server side technology is used for preventing duplication, for example, data submitted by cache and token comparison are prevented from being duplicated. The form anti-resubmission at the client side is realized by using a re-submission prevention function designed at the front end, the re-submission prevention function is cached in the local browser, and lawless persons can tamper with local files of the browser by using technical means and submit requests to the server side repeatedly, so that the safety of form submission is reduced. The data submission cache list duplication prevention and the token comparison duplication prevention belong to a server-side duplication prevention technology, and the former has the defects that the time complexity of list matching is increased linearly along with the increase of the length of a list, and the matching efficiency of data reaching a certain scale is lowered; the token comparison is important-preventing, namely the customer service side requests the server side for the token, and the client side submits the form submission request after taking the token, so that the response speed of the browser is theoretically delayed, and the form submission efficiency is reduced.
Based on the research, the invention provides a form repeated submission detection method, a repeated submission prevention mechanism is arranged on a back-end server, and the repeated submission prevention mechanism is not easy to be randomly tampered by lawless persons, so that the form submission safety is improved, in addition, the server side does not need to perform list matching, and the client side can achieve the repeated submission prevention purpose without waiting for a token, so that the processing speed of the server side is improved, and the form submission efficiency is improved.
The above-mentioned drawbacks are the results of the inventor after practical and careful study, and therefore, the discovery process of the above-mentioned problems and the solutions proposed by the present disclosure to the above-mentioned problems should be the contribution of the inventor in the process of the present disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
To facilitate understanding of this embodiment, first, a form repeat submission detecting method disclosed in the embodiment of the present disclosure is described in detail, where an execution subject of the form repeat submission detecting method provided in the embodiment of the present disclosure is generally a computer device with certain computing capability, and the computer device includes, for example: a terminal device, which may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal Digital Assistant (PDA), a handheld device, a computing device, a vehicle mounted device, a wearable device, or a server or other processing device. In some possible implementations, the form double submission detection method may be implemented by a processor calling computer readable instructions stored in a memory.
The form repeat submission detection method provided by the embodiment of the present disclosure is described below by taking an execution subject as a computer device as an example.
Example one
Referring to fig. 1, a flowchart of a form repeat submission detecting method provided in an embodiment of the present disclosure includes the following steps:
s101: and when a form submission request is received, generating a form identifier according to the form parameters carried in the form submission request, and writing the form identifier into the shared storage space.
In one possible implementation, the form identification may be a key-value pair consisting of a primary key and a key value, and the key-value pair store is the simplest form of organization of the database. Taking the form as an example of an order in the transaction system, the form parameter may be an order number, in this embodiment, both the primary key and the key value may be identified by the order number, and taking the order number as order _1213131 as an example, the primary key may be: order _1213131, the key value may also be: order _1213131, whereby the form identifications based on the same form parameters are the same and unique.
In specific implementation, the shared storage space may adopt a remote dictionary service (Redis) database, the Redis database is an open-source database written in ANSI (american national standards institute) C language, supports a network, is a memory-based or persistent log-type Key-Value database, and provides an application program interface in multiple languages, all operations of the Redis are atomicity, and the atomicity is that data change is performed either completely or not, so that a high-concurrency request scenario is satisfied.
S102: and if the form identifier is successfully written into the shared storage space within the preset time length, judging whether a form corresponding to the form identifier exists in the database.
In the distributed system, if a user repeatedly submits the same form through a client, at a server, the request submitted by the user may be distributed to different servers for processing, each server receiving the form submission request generates a form identifier according to form parameters and writes the form identifier into a shared storage space, and because the form parameters are the same, the form identifiers generated by the servers are also the same, so that when any server successfully writes the form identifier into the shared storage space, other servers cannot write the same form identifier into the shared storage space any more, thereby preventing multiple servers from repeatedly submitting repeated forms into a database.
In order to ensure the reliability of writing the form into the database, each server can try to rewrite the form again for many times under the condition that the form identifier is unsuccessfully written into the shared storage space, and in order to avoid the waste of server processing resource overhead caused by the fact that each server tries continuously, in the embodiment of the disclosure, a preset time length is set, when the server can successfully write the form identifier into the shared storage space within the preset time length, the step of writing the form into the database is continuously executed, and if the form identifier is unsuccessfully written into the shared storage space by the server within the preset time length, a response message of form submission failure is returned to the client, and the task of executing the current form is finished.
For a specific method flow for writing the form identifier into the shared memory space, reference is made to fig. 2, which will be described in detail in the second embodiment, and details are not described here again.
In a specific implementation, a database for storing the form may be a relational database, and the form is taken as a transaction order as an example, in this implementation, the form parameter may be an order number, when the server generates a corresponding key value pair according to the order number, the key value pair is stored in the Redis database, when the same key value pair already exists in the Redis database, the key value pair cannot be successfully stored, and if the server cannot store the generated key value pair in the Redis database within a preset time period, a response message of failure in submitting the form is returned to the client, and a task of executing the order is ended; if the same key value pair does not exist in the Redis database, the server successfully writes the key value pair into the Redis database within a preset time length, and then whether the form exists in the relational database is continuously judged. In specific implementation, the determination may be performed according to whether the same form identifier exists in the relational database, and in a case that the form identifier is represented by a key value pair, the determination may be performed by using a primary key, and if the same primary key exists in the relational database, it is determined that the form exists in the relational data, otherwise, it is determined that the form does not exist in the relational database.
S103: and writing the form into the database under the condition that the form does not exist in the database.
When the form is judged not to exist in the database according to the primary key in the key value pair, the form information is proved to be not established, the form is submitted for the first time and is not submitted repeatedly, so the form is written into the database, the form information of the form is established, whether the form information is established successfully needs to be judged again, after the form information is established, the key value pair corresponding to the form in the shared storage space is deleted, the feedback that the form is established successfully is returned, and when the form information is not established successfully, the key value pair corresponding to the form in the shared storage space is also deleted, but the feedback of failure is returned; when the form is judged to exist in the database according to the primary key in the key value pair, the fact that other servers write the information of the form into the database is proved, the form information is established for the form, and the key value pair of the form in the shared storage space is deleted, so that the form request of the current server is repeatedly submitted, the server does not write the form information into the database to avoid repetition, and the server also deletes the key value pair of the form established in the shared storage space.
The description continues with the form as an example of a trade order, such as a trade order for which an online course was purchased. When the order information is established, deleting the key value pair corresponding to the order in the Redis database, returning feedback of successful establishment of the order information to the client, and when the order information is not established successfully, deleting the key value pair corresponding to the order in the Redis database, but returning feedback of failure of establishment of the order information; when the order information exists in the relational database according to the primary key in the key value pair, it is proved that other servers write the order information into the relational database, the order information is established for the order, and the key value pair of the order in the Redis database is deleted, so that the order request of the current server is repeatedly submitted, the server does not write the order information into the relational database to avoid repetition, and the server also deletes the key value pair of the order established in the Redis database.
The embodiment of the disclosure generates the form identifier according to the form parameter in the form submission request, stores the form identifier in the shared storage space, judges whether the form exists in the database after the form identifier is successfully stored in the shared storage space, and writes the form into the database and deletes the form identifier in the shared storage space if the form does not exist in the database, so that a high concurrency request scene is met, and the problem of repeated submission of a distributed system can be solved.
Example two
In order to avoid the problem that the server processing resources are wasted because the same form identifier already exists in the shared storage space and cannot write the generated form identifier without continuously trying to write, in the embodiment of the present disclosure, the form identifier may be written into the shared storage space according to the flow shown in fig. 2, which specifically includes the following steps:
s201: and recording the first writing time while writing the form identification into the shared storage space.
For convenience of explanation, the first writing timing is recorded as t1, and the first writing timing in the embodiment of the present disclosure is explained with reference thereto.
S202: and judging whether the form identification is successfully written into the shared storage space, if so, executing step S203, and if not, executing step S204.
Because the form id of each form is unique, it cannot be written again when the same form id already exists in the shared memory space. Therefore, whether the writing of the form identifier to the shared storage space is successful can be judged according to the following procedures: after writing the form identifier into the shared storage space each time, receiving a feedback message of the shared storage space; if the feedback message is a write-in success message, determining that the writing of the form identifier into the shared storage space is successful, and executing step S203; if the feedback message is a write failure message, it is determined that the writing of the form identifier to the shared storage space fails, and then step S204 is executed.
S203: and executing the step of writing the form into the database, and ending the process.
In specific implementation, whether the form exists in the database can be continuously judged, and the form is written into the database under the condition that the form does not exist in the database. For specific implementation and steps, reference may be made to the description of step S102 in the first embodiment, and details are not described here.
S204: waiting for a preset time interval.
In specific implementation, the preset time interval may be set according to actual needs, which is not limited in the embodiment of the present disclosure, and for example, the preset time interval may be set to 300ms, 1s, 2s, and the like.
S205: and writing the form identification into the shared storage space, and recording the second writing time.
The second writing time is recorded as t2, and the second writing time in this embodiment is described with reference to this, after a preset time interval duration is waited, the generated form identifier is written into the shared storage space again, the second writing time t2 at this time is the previous writing time plus a preset time interval, the preset time interval is recorded as t3, and then the second writing time t2= the previous second writing time t2+ t3, and the process continues to return to the step S203.
S206: and judging whether the time interval between the second writing time and the first writing time is greater than a preset time length, if so, executing the step S207, and if not, executing the step S202.
When the first writing of the form identifier into the shared storage space fails, the second writing time t2 is equal to t1, the time interval at this time is 0, whether the time interval is greater than the preset time length is judged, if yes, step S207 is executed, and if not, step S205 is executed.
S207: and returning a response message of form submission failure to the client.
And when the time interval between the second writing time and the first writing time is longer than the preset time, the server stops executing the task of the current form and returns a response message of form submission failure to the client.
For better understanding of the embodiments of the present disclosure, the following describes a specific implementation process of the embodiments of the present disclosure by taking a form as an order in a trading system and taking a form identifier as a key value pair as an example, as shown in fig. 3, the following steps may be included:
s301: and the server receives an order request sent by the client.
S302: and generating a unique key value pair according to the request parameter of the order, storing the key value pair into a Redis database, and recording the first writing time t1 at the moment.
S303: and judging whether the set key value pair is successful, if so, executing step S306, and if not, executing step S304.
Because the key-value pair of each order is unique, the current key-value pair cannot be stored when the same key-value pair already exists in the Redis database.
S304: and waiting for a preset time interval, and recording the second writing time t2 after waiting.
S305: and judging whether the time t2-t1 is greater than the preset time length, if so, executing the step S312, and if not, executing the step S303.
S306: and judging whether the same order exists in the relational database, if so, executing step S311, and if not, executing step S307.
Because the key value pair of each order is unique, whether the same order exists in the relational database is judged according to the primary key in the key value pair of the current order, when the same order exists, it is shown that the order request is not submitted for the first time, the order information of the order is established and stored, the key value pair generated in the step S302 in the Redis database is deleted, and a failure is returned, and the flow is ended.
S307: and storing the order information into a relational database.
If the same order does not exist in the relational database, the fact that the order information of the order is not established is proved, the order request is submitted for the first time, and the order information established for the order is stored in the relational database.
S308: and judging whether the warehousing is successful, if so, executing step S309, and if not, executing step S311.
S309: deleting the generated key-value pair.
Step S310 is associated with step S, and after the order information is successfully created and stored in the relationship data, the key value pair generated in step S302 in the Redis database is deleted, and a response message indicating that the order submission is successful is returned to the client, ending the process.
S310: and returning to success, and ending the flow.
It should be noted that step S309 and step S310 do not have a certain sequential execution order, and both steps may be executed simultaneously, and step S310 may also be executed before step S309, which is not limited in the embodiment of the present disclosure.
S311: deleting the generated key-value pair.
This step is related to step S312, and when there is no identical order in the relationship database, but the server fails to create order information and store the order information in the relationship database, the key-value pair generated in step S302 in the Redis database is also deleted, and a response message indicating that the order submission failed is returned to the client, so that the process is ended.
S312: a failure is returned.
It should be noted that there is no certain sequential execution order between step S311 and step S312, the two steps may be executed simultaneously, and step S312 may also be executed before step S311, which is not limited in this disclosure.
According to the embodiment of the disclosure, the first writing time is recorded while the form identifier is written into the shared storage space, the form identifier is tried to be written into the shared storage space within the preset time duration according to the preset time interval, the second writing time is recorded while the form identifier is written into the shared storage space each time, until the writing is successful or the time interval between the second writing time and the first writing time is longer than the preset time duration, resource waste caused by ceaselessly trying to write the form identifier into the shared storage space by the server is avoided, the form can be prevented from being written repeatedly through judgment, and the reliability of form submission is effectively improved.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, the embodiment of the present disclosure further provides a device for detecting duplicate submission of a form, which corresponds to the method for detecting duplicate submission of a form.
EXAMPLE III
Referring to fig. 4, a schematic diagram of detection of repeated submission of a form according to a third embodiment of the present disclosure is shown, where the apparatus includes: a first writing module 401, a judging module 402 and a second writing module 403; wherein the content of the first and second substances,
the first writing module 401 is configured to, when a form submission request is received, generate a form identifier according to a form parameter carried in the form submission request, and write the form identifier into a shared storage space;
a determining module 402, configured to determine whether a form corresponding to the form identifier exists in a database if the first writing module successfully writes the form identifier into the shared storage space within a preset time period;
a second writing module 403, configured to write the form into the database when the determining module determines that the form does not exist in the database.
In a possible embodiment, the apparatus further comprises a recording module, wherein:
the recording module is used for recording a first writing time while the first writing module writes the form identifier into the shared storage space; recording a second writing time while the first writing module writes the form identifier into the shared storage space each time;
the first writing module is specifically configured to write a form identifier into the shared storage space according to a preset time interval; until the writing is successful or the time interval between the second writing time and the first writing time is greater than the preset time.
In a possible implementation manner, the determining module is specifically configured to determine whether writing of the form identifier into the shared storage space is successful according to the following procedure: after writing a form identifier into the shared storage space each time, receiving a feedback message of the shared storage space; if the feedback message is a write-in success message, determining that the writing of the form identifier into the shared storage space is successful; and if the feedback message is a write failure message, determining that the writing of the form identifier into the shared storage space fails.
In one possible embodiment, the form identification includes a key-value pair consisting of a primary key and a key-value, and the shared storage space includes a remote dictionary service Redis database; and
the judging module is specifically configured to judge whether a form corresponding to the form identifier exists in a database according to the primary key.
In one possible embodiment, the apparatus further comprises:
the first deleting module is used for deleting the form identifier from the shared storage space under the condition that the judging module judges that the form exists in the database;
and the first feedback module is used for returning a response message of failed submission aiming at the form submission request.
In one possible embodiment, the method further comprises:
a second deleting module, configured to delete the form identifier from the shared storage space after writing the form into the database;
the second feedback module is further used for returning a response message of successful submission aiming at the form submission request under the condition that the form is successfully written into the database; and under the condition that the form fails to be written into the database, returning a response message of failed submission aiming at the form submission request.
In one possible embodiment, the method further comprises:
and the third feedback module is used for returning a response message of failed submission aiming at the form submission request under the condition that the first writing module fails to write the form identifier into the shared storage space within a preset time length.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Example four
An embodiment of the present disclosure further provides a computer device, as shown in fig. 5, which is a schematic structural diagram of a computer device provided in the fourth embodiment of the present disclosure, and includes:
a processor 51 and a memory 52; the memory 52 stores machine-readable instructions executable by the processor 51, the processor 51 being configured to execute the machine-readable instructions stored in the memory 52, the processor 51 performing the following steps when the machine-readable instructions are executed by the processor 51: s101: when a form submission request is received, generating a form identifier according to form parameters carried in the form submission request, and writing the form identifier into a shared storage space; s102: if the form identification is successfully written into the shared storage space within the preset time length, judging whether a form corresponding to the form identification exists in the database or not; s103: and writing the form into the database under the condition that the form does not exist in the database.
The storage 52 includes a memory 521 and an external storage 522; the memory 521 is also referred to as an internal memory, and temporarily stores operation data in the processor 51 and data exchanged with an external memory 522 such as a hard disk, and the processor 51 exchanges data with the external memory 522 through the memory 521.
The embodiment of the present disclosure further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the steps of the form repeat submission detection method described in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The computer program product of the form repeat submission detection method provided in the embodiments of the present disclosure includes a computer-readable storage medium storing a program code, where instructions included in the program code may be used to execute the steps of the form repeat submission detection method described in the above method embodiments, which may be referred to in the above method embodiments specifically, and are not described herein again.
The embodiments of the present disclosure also provide a computer program, which when executed by a processor implements any one of the methods of the foregoing embodiments. The computer program product may be embodied in hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK) or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (9)

1. A form repeated submission detection method is characterized by being applied to a distributed system; the distributed system includes a plurality of servers including:
when a form submission request is received, generating a form identifier according to form parameters carried in the form submission request, and writing the form identifier into a shared storage space;
recording a first writing time while writing the form identifier into the shared storage space; and
writing a form identifier into the shared storage space within a preset time according to the following steps:
writing form identifications into the shared storage space according to a preset time interval;
recording a second writing time while writing the form identifier into the shared storage space each time until the writing is successful or the time interval between the second writing time and the first writing time is greater than the preset duration;
if the writing of the form identifier into the shared storage space within the preset duration is successful, judging whether a form corresponding to the form identifier exists in a database or not;
and writing the form into the database under the condition that the form does not exist in the database.
2. The method of claim 1, wherein determining whether writing the form id to the shared memory space is successful is performed according to the following procedure:
after writing a form identifier into the shared storage space each time, receiving a feedback message of the shared storage space;
if the feedback message is a write success message, determining that the writing of the form identifier into the shared storage space is successful;
and if the feedback message is a write failure message, determining that the writing of the form identifier into the shared storage space fails.
3. The method of claim 1 or 2, wherein the form identification comprises a key-value pair consisting of a primary key and a key-value, and wherein the shared memory space comprises a remote dictionary service; and
judging whether a form corresponding to the form identifier exists in a database, specifically comprising:
and judging whether a corresponding form exists in the database or not according to the primary key.
4. The method of claim 1, further comprising:
deleting the form identification from the shared storage space under the condition that the form exists in the database;
and returning a response message of failed submission aiming at the form submission request.
5. The method of claim 1, after writing the form to the database, further comprising:
deleting the form identification from the shared memory space; and
under the condition that the form is successfully written into the database, returning a response message of successful submission aiming at the form submission request; and in the case of failure of writing the form into the database, returning a response message of failed submission aiming at the form submission request.
6. The method of claim 1, further comprising:
and under the condition that writing of the form identifier into the shared storage space fails within a preset time length, returning a response message of failed submission aiming at the form submission request.
7. The device for detecting the repeated submission of the form is applied to a distributed system, wherein the distributed system comprises a plurality of servers and comprises:
the first writing-in module is used for generating a form identifier according to the form parameters carried in the form submission request and writing the form identifier into a shared storage space when the form submission request is received;
the execution module is used for recording a first writing moment while writing the form identifier into the shared storage space; and
within a preset time length, writing a form identifier into the shared storage space according to the following steps:
writing form identifications into the shared storage space according to a preset time interval;
recording a second writing time while writing the form identifier into the shared storage space each time until the writing is successful or the time interval between the second writing time and the first writing time is longer than the preset time;
the judging module is used for judging whether a form corresponding to the form identifier exists in a database or not if the first writing module successfully writes the form identifier into the shared storage space within a preset time length;
and the second writing module is used for writing the form into the database under the condition that the judging module judges that the form does not exist in the database.
8. A computer device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when a computer device is run, the machine-readable instructions when executed by the processor performing the steps of the method of form repeat submission detection as claimed in any of claims 1 to 6.
9. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the steps of the method of form repeat submission detection as claimed in any of claims 1 to 6.
CN202011109864.9A 2020-10-16 2020-10-16 Form repeated submission detection method and device, computer equipment and storage medium Active CN112256776B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011109864.9A CN112256776B (en) 2020-10-16 2020-10-16 Form repeated submission detection method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011109864.9A CN112256776B (en) 2020-10-16 2020-10-16 Form repeated submission detection method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112256776A CN112256776A (en) 2021-01-22
CN112256776B true CN112256776B (en) 2022-11-22

Family

ID=74244436

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011109864.9A Active CN112256776B (en) 2020-10-16 2020-10-16 Form repeated submission detection method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112256776B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112905163B (en) * 2021-03-15 2024-04-16 上海万物新生环保科技集团有限公司 Form submitting method and device
CN113034253A (en) * 2021-03-18 2021-06-25 上海嵩恒网络科技股份有限公司 Early warning method, electronic device and storage medium
CN113377855A (en) * 2021-06-25 2021-09-10 芜湖雄狮汽车科技有限公司 Method and device for preventing form from being resubmitted, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105139191A (en) * 2015-09-15 2015-12-09 联动优势电子商务有限公司 Method and device for obtaining order information
CN109922132A (en) * 2019-01-18 2019-06-21 深圳壹账通智能科技有限公司 Method, apparatus, electronic equipment and the storage medium of form request processing
CN110472173A (en) * 2019-08-19 2019-11-19 珠海格力电器股份有限公司 The method, apparatus and storage medium that list is submitted
CN111339070A (en) * 2020-02-20 2020-06-26 上海二三四五网络科技有限公司 Order repeated submission control method and device
CN111506445A (en) * 2020-04-21 2020-08-07 北京思特奇信息技术股份有限公司 Method and system for preventing repeated malicious ordering of commodities based on REDIS cache

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060265380A1 (en) * 2005-05-23 2006-11-23 Jared Fry Methods, systems, and computer program products for preventing double form submission at a user agent

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105139191A (en) * 2015-09-15 2015-12-09 联动优势电子商务有限公司 Method and device for obtaining order information
CN109922132A (en) * 2019-01-18 2019-06-21 深圳壹账通智能科技有限公司 Method, apparatus, electronic equipment and the storage medium of form request processing
CN110472173A (en) * 2019-08-19 2019-11-19 珠海格力电器股份有限公司 The method, apparatus and storage medium that list is submitted
CN111339070A (en) * 2020-02-20 2020-06-26 上海二三四五网络科技有限公司 Order repeated submission control method and device
CN111506445A (en) * 2020-04-21 2020-08-07 北京思特奇信息技术股份有限公司 Method and system for preventing repeated malicious ordering of commodities based on REDIS cache

Also Published As

Publication number Publication date
CN112256776A (en) 2021-01-22

Similar Documents

Publication Publication Date Title
CN112256776B (en) Form repeated submission detection method and device, computer equipment and storage medium
US20210165686A1 (en) Task processing method, system, device, and storage medium
CN105095462B (en) Handle the method and system of webpage repetitive requests
EP2877942B1 (en) Automatic transaction retry after session failure
US20160191662A1 (en) Automatic data request recovery after session failure
WO2021098139A1 (en) Method and device for storing state data of cross-chain transaction, and storage medium
CN110019873B (en) Face data processing method, device and equipment
CN109981715B (en) Session management method and device
JP6655731B2 (en) Self-protection security device based on system environment and user behavior analysis and its operation method
CN113568981A (en) Transaction data processing method, device, equipment and medium
CN112053149A (en) Method and device for preventing repeated payment, electronic equipment and readable storage medium
CN106973008B (en) Method for realizing selective mail withdrawal
CN107644263A (en) Method and server are handled in banking reservation
CN111324622A (en) Resource first-aid-purchase processing method, device, equipment and storage medium
US8234243B2 (en) Third tier transactional commit for asynchronous replication
US11221894B2 (en) Event execution method, device, and system
CN105574026A (en) Method and device for service supporting by using non-relational database
CN109819000A (en) Methods, devices and systems and machine readable storage medium for PUSH message
CN109246077B (en) Distributed concurrent transaction verification method, device and computer storage medium
CN105095303B (en) Quick link pushing method and quick link pushing device
CN110392059A (en) A kind of conversation managing method, device and storage medium
CN115858668A (en) Distributed transaction processing method, device, electronic device and storage medium
CN113835780A (en) Event response method and device
CN113704644A (en) Verification code display method and device, computer equipment and storage medium
CN108875349B (en) Verification code generation method and device based on pinyin

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