CN109670975B - Method, medium, and electronic device for generating a single number in a computer system - Google Patents

Method, medium, and electronic device for generating a single number in a computer system Download PDF

Info

Publication number
CN109670975B
CN109670975B CN201811541767.XA CN201811541767A CN109670975B CN 109670975 B CN109670975 B CN 109670975B CN 201811541767 A CN201811541767 A CN 201811541767A CN 109670975 B CN109670975 B CN 109670975B
Authority
CN
China
Prior art keywords
database
maximum
single number
generating
variable
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
CN201811541767.XA
Other languages
Chinese (zh)
Other versions
CN109670975A (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.)
Taikang Insurance Group Co Ltd
Original Assignee
Taikang Insurance Group 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 Taikang Insurance Group Co Ltd filed Critical Taikang Insurance Group Co Ltd
Priority to CN201811541767.XA priority Critical patent/CN109670975B/en
Publication of CN109670975A publication Critical patent/CN109670975A/en
Application granted granted Critical
Publication of CN109670975B publication Critical patent/CN109670975B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/08Insurance

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method, medium and electronic equipment for generating a single number in a computer system, wherein the computer system comprises a first database and a second database, the first database and the second database are used for storing at least a maximum value variable, and the first database is also used for storing a recently generated single number, and the method comprises the following steps: receiving a request for generating a single number; searching the first database aiming at the request for generating the single number; if the newly generated single number is found in the first database, generating a new single number according to the newly generated single number; otherwise, generating a new single number according to the maximum value variable stored in the first database or the second database; storing the new sheet number in the first database as the most recently generated sheet number. The invention realizes the high efficiency and uniqueness of generating the single number, is suitable for generating the single number in a high concurrency environment, and improves the safety of data storage.

Description

Method, medium, and electronic device for generating a single number in a computer system
Technical Field
The invention relates to the technical field of data processing and storage, in particular to a technology for generating a single number, and more particularly to a technology suitable for generating the single number in a high-concurrency environment. A highly concurrent environment refers to an environment in which a large number of system requests are processed concurrently in parallel.
Background
The insurance policy number is the number of the insurance contract issued by the insurance company after the insurant successfully insurs the insurance company. There are currently two common methods of generating policy numbers: one approach is to store the generated maximum policy number in a relational database (e.g., Mysql database), generate a new policy number by reading the generated maximum policy number from the relational database and employing a sequence number self-growth technique; another approach is to store all generated policy numbers in a relational database and generate a new policy number by generating a random number, which requires retrieving in the relational database whether the generated random number already exists and, if so, regenerating the random number. Both of these methods require frequent searches of the relational database, where the former requires searching the generated maximum policy number before each generation of a new policy number, and the latter requires searching all generated policy numbers to determine whether the generated random number is a duplicate of the generated policy number. These searches result in a long time consuming generation of the policy number, and thus both methods are difficult to adapt to a high concurrency environment.
A memory database (e.g., a Redis database) is a database that loads data in a memory and directly operates, and compared to a relational database, the data read/write speed of the memory database is higher by several orders of magnitude, and supports operations of data types such as Strings, Lists, Hashes, Sets, Ordered Sets, and the like. If the memory database is used for the two methods to generate the policy number, the efficiency of generating the policy number can be greatly improved. However, the security of the in-memory database is low, and the in-memory database has the problem of losing data when power is lost. Therefore, how to improve the security of data storage on the basis of efficiently generating the policy number by using the memory database and ensure the uniqueness of the generated policy number is a problem to be solved at present.
Disclosure of Invention
To solve the above problems in the prior art, according to an embodiment of the present invention, there is provided a method for generating a single number in a computer system, the computer system including a first database and a second database, wherein the first database and the second database are used for storing at least a maximum value variable, and the first database is further used for storing a most recently generated single number, the method including: receiving a request for generating a single number; searching the first database aiming at the request for generating the single number; if the newly generated single number is found in the first database, generating a new single number according to the newly generated single number; otherwise, generating a new single number according to the maximum value variable stored in the first database or the second database; storing the new sheet number in the first database as the most recently generated sheet number.
The above method may further comprise: when the difference value between the maximum variable and the new single sign is smaller than a preset threshold value, updating the maximum variable stored in the first database and the second database.
In the above method, the maximum value variable stored in the first database and the second database is updated according to the following formula:
maximum*=maximum+increstep+step
the maximum variable is represented by maximum, the maximum variable is represented by maximum after updating, incremecept is a preset constant, and step is the number of the single signs which are required to be generated for the request and are specified in the request for generating the single signs.
In the above method, generating a new single number according to the maximum value variable stored in the first database or the second database includes: if the maximum variable is found in the first database, taking the maximum variable as the latest generated single number, and adding the latest generated single number and a preset value to obtain a new single number; otherwise, storing the maximum variable in the second database into the first database, taking the maximum variable as the most recently generated single number, and adding the most recently generated single number and a preset value to obtain a new single number.
The method further includes updating a maximum variable in the first database and the second database according to:
maximum*=maximum+increstep
where maximum denotes a maximum variable, maximum denotes an updated maximum variable, and incremecept is a predetermined constant.
In the above method, the initial value of the maximum variable is obtained by monitoring the concurrency number of requests for generating a single number at the same time.
In the above method, if the request for generating a single number specifies more than one single number to be generated, the method further includes: judging whether the number of the generated single numbers for the request for generating the single numbers meets the request for generating the single numbers or not, and searching the first database if the number of the generated single numbers does not meet the request for generating the single numbers; if the newly generated single number is found in the first database, generating a new single number according to the newly generated single number; otherwise, generating a new single number according to the maximum value variable stored in the first database or the second database.
In the above method, the first database is an in-memory database, and the second database is a relational database.
According to an embodiment of the invention, there is also provided a computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to the above-mentioned embodiment.
There is also provided, in accordance with an embodiment of the present invention, electronic apparatus including: one or more processors; memory for storing one or more computer programs that, when executed by the one or more processors, cause the electronic device to implement the method according to the above embodiments.
The invention has the following beneficial effects:
the memory database is introduced to store the most recently generated single number (namely the generated maximum single number), and the memory database has high reading and writing efficiency, so that the time consumed by generating the single number is reduced, and the method is suitable for generating a plurality of single numbers in a high-concurrency environment. And a relational database is also introduced, the relational database and the memory database synchronize a maximum value variable, and the maximum value variable is used for generating a new single number which is not repeated with the generated single number under the condition that the searching of the newly generated single number fails, so that the safety of data storage is improved. In addition, the maximum variable does not need to be updated every time a new single number is generated, so that the read-write interaction with a relational database is reduced, and the efficiency is further improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort. In the drawings:
FIG. 1 schematically illustrates a system architecture diagram for generating a ticket number according to one embodiment of the invention;
FIG. 2 schematically illustrates a flow diagram of a method of generating a single number according to one embodiment of the invention;
FIG. 3 schematically illustrates a flow diagram of a method of generating a single number according to another embodiment of the invention;
FIG. 4 schematically illustrates a flow diagram of a method of generating a single number according to yet another embodiment of the invention;
FIG. 5 schematically illustrates a block diagram of a computer system suitable for use with an electronic device to implement an embodiment of the invention.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to provide a thorough understanding of embodiments of the invention. One skilled in the relevant art will recognize, however, that the invention may be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations or operations have not been shown or described in detail to avoid obscuring aspects of the invention.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
According to one embodiment of the present invention, there is provided a method of generating a single number, wherein the single number is represented as a number having a fixed bit length, the categories of the single number including, but not limited to: insurance policy number, serial number, express bill number, account book number, etc. The method of generating a single number utilizes two databases: a memory database and a relational database. In summary, the method of generating a single number comprises: storing the most recently generated single number in the memory database and synchronizing a maximum variable between the memory database and the relational database; aiming at the request for generating the single number, searching the newly generated single number in the memory database, if the newly generated single number is found, generating a new single number according to the newly generated single number, otherwise, generating a new single number according to the synchronous maximum variable; and updating the most recently generated single number in the memory database, and updating the maximum variable in the memory database and the relational database when the difference value between the maximum variable and the most recently generated single number is smaller than the early warning amount.
The method of generating the ticket number is performed in a computing device having computing and storage capabilities, which may be located at a server or client, for example, in a short-risk core (SIC) system, an insurance industry core business system, and which is capable of interacting with a database. Referring to fig. 1, a connection structure of the SIC system and an in-memory database (Redis database), a relational database (Mysql database) for performing the method of generating a single number is schematically shown. It should be noted that although the two databases are depicted in fig. 1 as being independent of the SIC system, the two databases may also be located in a computing device for performing the method of generating the single number.
The steps of the method of generating the sheet number, including steps S201-S213, are described in detail below with reference to fig. 2:
s201, preprocessing.
Setting an initial value of a maximum variable and values of two constants (respectively, a maximum step length and an early warning amount), and storing the maximum variable, the maximum step length and the early warning amount in a local configuration file. As will be described in detail below, the maximum variable is used as a reference variable when a query fails to a most recently generated sheet number to generate a new sheet number; the early warning value is used for determining whether the maximum variable needs to be updated; and the maximum step size is used to update the maximum variable.
The initial value of the maximum variable may be obtained by monitoring the concurrent number of requests for generating a single number at the same time. According to one embodiment of the invention, the number of requests for generating a single number at a plurality of times is monitored, and the average value of the number of requests at different times is used as the initial value of the maximum variable. According to an embodiment of the present invention, the initial value of the maximum variable, the value of the maximum step size, and the value of the warning amount may be different, wherein the value of the maximum step size and the value of the warning amount may be empirically selected. Preferably, according to an embodiment of the present invention, the initial value of the maximum variable is equal to the maximum step size and the value of the warning amount, for example, 500.
S202, receiving a request for generating one or more single numbers from a user, wherein the request comprises the number step of the single numbers to be generated.
In addition to the number of single numbers, the prefix and length of the final single number information to be output may also be indicated in the request. For example, the prefix is "CH" and the length is 16 characters.
S203, searching a maximum variable, a maximum step length and an early warning amount in the memory database, executing the step S207 if the maximum variable, the maximum step length and the early warning amount are found, and executing the step S204 if at least one of the maximum variable, the maximum step length and the early warning amount fails to be found.
Wherein the in-memory database includes but is not limited to: redis database, Memcached database, etc. In the invention, the memory database is used for storing the most recently generated single number (the single number is usually generated from small to large, so the most recently generated single number is the generated maximum single number), the maximum value variable, the maximum step length and the early warning value. Since the security of the memory database is low, the newly generated single number stored in the memory database may be lost due to reasons such as power failure, excessive memory usage in the buffer area, and the like, in this case, a new single number needs to be generated according to the maximum variable (and the maximum step size and the warning value are used for updating the maximum variable).
And S204, searching a maximum variable, a maximum step length and an early warning amount in a relational database (note that if only one or two of the maximum variable, the maximum step length and the early warning amount fails to be searched, only a variable and/or a constant which fails to be searched in the relational database needs to be searched), if the search is successful, executing the step S205, otherwise, executing the step S206.
The relational database can adopt any one of Mysql, Oracle, db2, Sqlserver, Sybase and other databases, and the security is high. The relational database is used for storing a maximum variable, a maximum step length and an early warning amount, and when data in the memory database are lost, the relational database with higher safety can replace the relational database to provide the maximum variable, the maximum step length and the early warning amount so as to be used for generating a new single number and updating the maximum variable. If the search is not performed in the relational database, which means that the generation of the ticket number has not been performed, the process proceeds to step S206 (i.e., searching from the local configuration file).
S205, load the maximum variable, the maximum step size, and the warning amount in the relational database into the in-memory database (or load only the variable and/or the constant that failed the previous search into the in-memory database), and then execute step S207.
S206, reading the maximum variable, the maximum step length and the early warning amount from the local configuration file, and storing the maximum variable, the maximum step length and the early warning amount in a memory database and a relational database. Further, since generation of the single number has not been performed yet, the newly generated single number is also set in the memory database, and its initial value is set to 0.
S207, searching the newly generated single number in the memory database, and executing the step S209 if the searching is successful, or executing the step S208.
And S208, storing the maximum variable in the memory database as the latest generated single number.
S209, adding 1 to the most recently generated single number in the memory database to serve as a new single number, and updating the most recently generated single number in the memory database by using the new single number. According to an embodiment of the present invention, in addition to adding 1, a newly generated single number may be added with a predetermined integer to be a new single number.
S210, comparing the maximum value variable in the memory database with the newly generated single number (namely, a new single number), if the difference value obtained by subtracting the newly generated single number from the maximum value variable is more than or equal to the early warning amount in the memory database, executing step S212, otherwise executing step S211.
S211, updating the maximum variable according to the following formula, and storing the updated maximum variable into the memory database and the relational database:
maximum*=maximum+increstep+step (1)
wherein, maximum represents the maximum variable after updating, incrustep represents the maximum step size, and step represents the number of single numbers to be generated for the user request.
And S212, generating and outputting final single number information.
According to one embodiment of the invention, the final single number information is formed from the generated new single number, the prefix and the length indicated in the user request. For example, assuming that the new single number is 1234, the prefix is "CH", and the length is 16 characters, the final single number information may be "CH 00000000001234".
S213, judging whether the number of the generated single numbers meets the user request, namely judging whether step single numbers are generated, if step single numbers are generated, ending the generation of the single numbers, otherwise returning to the step S207, and continuing to generate the single numbers.
From the above steps S201-S213, if the query of the recently generated single number in the memory database is successful, a new single number can be generated directly according to the recently generated single number, and the memory database has a characteristic of fast reading and writing, so that the efficiency of generating the single number is ensured to be high. Since the maximum variable is stored in the memory database in advance, even if the memory database loses the most recently generated single number, a new single number can be generated according to the maximum variable in the memory database. The initial value of the maximum variable is set according to the concurrency number of the requests at the same time, and the maximum variable is updated under the condition that the difference value between the maximum variable and the new single number is smaller than the early warning amount, so that the generated new single number cannot be repeated with the generated single number under the condition that the new single number is generated according to the maximum variable. In addition, according to the above maximum variable updating formula, it can be seen that the maximum step size and the number of the single numbers required to be generated are added for each updating, so that the updating of the maximum variable is not too frequent, the number of times of updating the maximum variable in the relational database is reduced, that is, the interaction with the relational database is reduced, and the single number generating efficiency is further improved.
In the above embodiment, it is determined whether the maximum variable needs to be updated after a new single number is generated and used to update the most recently generated single number in the in-memory database. In the above-described embodiment, if a new single sign is generated by replacing the most recently generated single sign with the maximum value variable, the value of the maximum value variable is equal to or less than the most recently generated single sign when the new single sign is generated and the most recently generated single sign is updated. In view of the high concurrency environment, a case where the value of the maximum variable is smaller than the most recently generated single sign (in this case, a repeated single sign may be generated) should be avoided. Therefore, in another embodiment, the maximum variable in the in-memory database may be updated after being stored as the most recently generated single number so that the value of the maximum variable is not less than the most recently generated single number.
Referring to fig. 3, a method for generating a sheet number according to another embodiment of the present invention is shown, the method for generating a sheet number is executed in a computing device with computing and storing functions, the computing device may be located at a server or a client, and the method specifically includes the following steps:
s301, a pretreatment process comprises the following steps: setting an initial value of a maximum variable, a maximum step length and a value of an early warning quantity, and storing the maximum variable, the maximum step length and the early warning quantity in a local configuration file.
S302, a request for generating one or more single numbers is received from a user, and the request comprises the number step of the single numbers to be generated. In addition to the number of single numbers, the prefix and length of the final single number information to be output may also be indicated in the user request.
And S303, searching a maximum value variable, a maximum step length and an early warning amount in the memory database, executing the step S307 if the searching is successful, and executing the step S304 if the searching is not successful.
S304, searching a maximum value variable, a maximum step length and an early warning quantity (or searching a variable and/or a constant which is failed to be searched previously) in the relational database, if the searching is successful, executing the step S305, otherwise, executing the step S306.
S305, loading the maximum value variable, the maximum step length and the early warning amount in the relational database into the memory database (or loading only the variable and/or the constant which are failed to be searched previously into the memory database), and executing the step S307.
S306, reading the maximum variable, the maximum step length and the early warning amount from the local configuration file, and storing the maximum variable, the maximum step length and the early warning amount in a memory database and a relational database. And, the most recently generated single number is set in the memory database and its initial value is set to 0.
S307, searching the newly generated single number in the memory database, if the searching is successful, executing the step S310, otherwise, executing the step S308.
S308, storing the maximum value variable in the memory database as the latest generated single number.
S309, updating the maximum variable according to the following formula, and storing the updated maximum variable into the memory database and the relational database:
maximum*=maximum+increstep (2)
wherein maximum represents the maximum variable, maximum x represents the updated maximum variable, and incretep represents the maximum step size.
And S310, adding 1 to the most recently generated single number in the memory database to serve as a new single number, and updating the most recently generated single number in the memory database by using the new single number.
S311, comparing the maximum variable in the memory database with the single number generated recently, if the difference obtained by subtracting the single number generated recently from the maximum variable is more than or equal to the early warning amount in the memory database, executing the step S313, otherwise executing the step S312.
And S312, updating the maximum variable according to the formula (1), and storing the updated maximum variable into the memory database and the relational database.
And S313, generating and outputting final single number information.
S314, judging whether the number of the generated single numbers meets the user request, namely judging whether step single numbers are generated, if step single numbers are generated, ending the generation of the single numbers, otherwise returning to the step S307, and generating the next single number.
As can be seen from the above steps S301 to S314, in addition to ensuring that the value of the maximum variable is not less than the most recently generated single number, the maximum variable is updated again when the difference between the maximum variable and the new single number is less than the warning amount, so that the value of the maximum variable becomes larger after two updates, the update frequency of the maximum variable is further reduced, and the uniqueness of the generated new single number is ensured. It will be understood by those skilled in the art that although the above-described embodiment describes replacing the most recently generated single sign with the maximum value variable and updating the value of the maximum value variable in the order of steps S308 and S309, the two steps may be performed simultaneously.
While the above two embodiments provide methods for generating a single number of the same category, according to another embodiment of the present invention, there is also provided a method for generating a single number for different categories of single numbers, the method for generating a single number is executed in a computing device with computing and storing functions, and the computing device can be located at a server or a client. Referring to fig. 4, the method of generating a single number includes the steps of:
s401, a pretreatment process, comprising: setting an initial value of a corresponding maximum variable, a corresponding maximum step length and an early warning amount value aiming at each single number category, and storing the maximum variable, the maximum step length and the early warning amount corresponding to each single number category in a local configuration file.
S402, receiving a request for generating one or more single numbers from a user, wherein the request comprises the number step of the single numbers to be generated and the category of the single numbers. Wherein the single number category indicates whether the single number to be generated is a policy number, a serial number, an account number, or the like. For example, the single number category is "CHDR," which indicates that the single number category is a policy number. In addition, the prefix and the length of the final single number information to be output can also be indicated in the user request.
And S403, searching a maximum variable, a maximum step length and an early warning amount corresponding to the single number type requested by the user in the memory database (see back to FIG. 1, which shows the maximum variable, the maximum step length and the early warning amount corresponding to the single number type 'CHDR' in the memory database), executing step S407 if the search is successful, otherwise executing step S404.
S404, searching a maximum value variable, a maximum step length and an early warning amount (or searching a variable and/or a constant which is failed to search previously) corresponding to the single number type requested by the user in a relational database, if the searching is successful, executing the step S405, otherwise, executing the step S406.
S405, loading the maximum variable, the maximum step size, and the early warning amount corresponding to the single number category requested by the user in the relational database into the memory database (or loading only the variable and/or the constant that failed to be searched previously into the memory database), and then executing step S407.
S406, reading a maximum value variable, a maximum step length and an early warning amount corresponding to the single number type requested by the user from the local configuration file, and storing the maximum value variable, the maximum step length and the early warning amount in a memory database and a relational database; and, number, and its initial value is set to 0.
And S407, searching the latest generated single number corresponding to the single number category requested by the user in the memory database, and executing the step S410 if the searching is successful, or executing the step S408 if the searching is not successful.
Referring back to fig. 1, the memory database may be a memory database of a type using key-value pairs (key _ value), where key represents a single number category, such as "CHDR", "SKNO", etc., and value represents a most recently generated single number corresponding to a different single number category.
And S408, storing the maximum variable corresponding to the single number category requested by the user in the memory database as the most recently generated single number corresponding to the category.
And S409, updating the maximum value variable corresponding to the single number type requested by the user according to the formula (2) and storing the maximum value variable into a memory database and a relational database.
And S410, adding 1 to the newly generated single number corresponding to the single number type requested by the user in the memory database to serve as a new single number, and updating the newly generated single number corresponding to the type in the memory database, such as updating the value corresponding to key 'CHDR'.
S411, comparing the maximum value variable corresponding to the single number category requested by the user in the memory database with the most recently generated single number corresponding to the category, if the difference value is greater than or equal to the early warning amount in the memory database, executing step S413, otherwise executing step S412.
And S412, updating a maximum value variable corresponding to the single number type requested by the user according to the formula (1) above, and storing the maximum value variable into a memory database and a relational database.
And S413, generating and outputting final single number information.
S414, judging whether the number of the generated single numbers meets the user request, namely judging whether step single numbers are generated, if step single numbers are generated, ending the generation of the single numbers, otherwise returning to the step S407, and generating the next single number.
In the above-described embodiment, the length and the prefix of the final single number information may be included in the user request, may be pre-stored in the local configuration file, or may be stored in other locations, for example, in the in-memory database and/or the relational database. In the above embodiments, before searching the most recently generated single number, it is searched whether the maximum variable, the maximum step size, and the warning amount exist in the in-memory database. In other embodiments, it may also be possible to search whether the maximum variable, the maximum step size, and/or the warning amount exists in the memory database before using the maximum variable and updating the maximum variable, and if the search fails, continue to search the data from the relational database (if the single number is generated for the first time, further search the data from the local configuration file), so that even if the memory database suddenly fails due to power failure or other reasons, it is ensured that the unique single number is generated smoothly after recovery.
According to an embodiment of the present invention, there is also provided a schematic structural diagram of a computer system suitable for use in implementing the electronic device of the embodiment of the present invention. Referring to FIG. 5, a computer system 500 includes a bus 505 that enables devices coupled to the bus 505 to communicate information quickly. The processor 501 is coupled to the bus 505 for performing a set of actions or operations specified by the computer program code, and the processor 501 may be implemented as mechanical, electrical, magnetic, optical, quantum, or chemical components, among others, alone or in combination with other devices.
The computer system 500 further includes a memory 503 coupled to the bus 505, the memory 503 (e.g., RAM or other dynamic storage device) storing data that may be altered by the computer system 500, including instructions or computer programs implementing the methods of generating a ticket described in the embodiments above. The instructions or computer program, when executed by the processor 501, enable the computer system 500 to implement the method of generating a ticket number described in the embodiments above, e.g., the various steps as shown in fig. 2-4 may be implemented. The memory 503 may also store temporary data generated during execution of instructions or computer programs by the processor 501, as well as various programs and data required for system operation. Computer system 500 also includes a read only memory 502 coupled to bus 505, and a non-volatile storage device 508, such as a magnetic disk or optical disk, for storing data that persists when the computer system 500 is turned off or otherwise loses power.
The computer system 500 also includes input devices 506, such as a keyboard, sensors, etc., and output devices 507, such as a Cathode Ray Tube (CRT), Liquid Crystal Display (LCD), printer, etc. Computer system 500 also includes a communication interface 504 coupled to bus 505, where communication interface 504 may provide a one-way or two-way communication coupling to an external device. For example, communication interface 504 may be a parallel port, a serial port, a telephone modem, or a Local Area Network (LAN) card. The computer system 500 further includes a drive device 509 coupled to the bus 505, and a removable device 510 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, which is mounted on the drive device 509 as necessary, so that a computer program read out therefrom is mounted into the storage device 508 as necessary.
According to another embodiment of the present invention, a computer-readable medium is also provided, which may be included in the computer system 500 or exist separately without being assembled into the computer system 500. The computer readable medium carries one or more computer programs or instructions which, when executed by a processor, cause the computer system 500 to implement the method of generating a ticket number described in the embodiments above. Note that computer-readable media refers to any medium that provides data to processor 501, and such media can take any form, including, but not limited to, computer-readable storage media (e.g., non-volatile media, volatile media), and transmission media. Non-volatile media include, for example, optical or magnetic disks, such as storage device 508; volatile media includes, for example, memory 504. Transmission media include, for example, coaxial cables, copper wire, fiber optic cables, and carrier waves that travel through space without cables or wires, such as acoustic waves and electromagnetic waves, including radio, optical and infrared waves. The general form of the computer readable medium includes: a floppy disk, a flexible disk, hard disk, magnetic tape, any other magnetic medium, a CD-ROM, CDRW, DVD, any other optical medium, punch cards, paper tape, optical mark sheets, any other physical medium with patterns of holes or other optically recognizable indicia, a RAM, a PROM, an EPROM, a FLASH-EPROM, any other memory chip or cartridge, a carrier wave, or any other medium from which a computer can read.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (8)

1. A method of generating a single number in a computer system, the computer system comprising a first database and a second database, wherein the first database and the second database are for storing at least a maximum value variable and the first database is further for storing a most recently generated single number, the method comprising:
monitoring the number of requests for generating single numbers at multiple moments, taking the average value of the number of the requests at the multiple moments as the initial value of the maximum variable, and storing the initial value in the first database and the second database;
receiving a request for generating a single number;
searching the first database aiming at the request for generating the single number;
if the newly generated single number is found in the first database, generating a new single number according to the newly generated single number;
otherwise, generating a new single number according to the maximum value variable stored in the first database or the second database, and updating the maximum value variable stored in the first database and the second database for the first time;
storing the new sheet number in the first database as the most recently generated sheet number;
updating the maximum variable stored in the first database and the second database a second time when the difference between the maximum variable and the new single sign is less than a predetermined threshold, wherein the updating of the maximum variable comprises adding a maximum step size.
2. The method of claim 1, wherein the maximum variable stored in the first database and the second database is updated a second time according to:
maximum*=maximum+increstep+step
the maximum variable is represented by maximum, incremep is represented by maximum step and is a predetermined constant, and step is the number of the single signs which are required to be generated for the request and are specified in the request for generating the single signs.
3. The method of claim 1 or 2, wherein generating a new single number from a maximum variable stored in the first database or the second database comprises:
if the maximum variable is found in the first database, taking the maximum variable as the latest generated single number, and adding the latest generated single number and a preset value to obtain a new single number;
if the maximum variable is not found in the first database, storing the maximum variable in the second database into the first database, taking the maximum variable as the most recently generated single number, and adding the most recently generated single number and a preset value to obtain a new single number.
4. The method of claim 3, further comprising first updating a maximum variable in the first database and the second database according to:
maximum*=maximum+increstep
where maximum denotes a maximum variable, maximum denotes an updated maximum variable, and incremecept denotes a maximum step size, which is a predetermined constant.
5. The method of claim 1 or 2, wherein if the request to generate a single number specifies more than one number of single numbers that need to be generated, the method further comprises:
judging whether the number of the generated single numbers for the request for generating the single numbers meets the request for generating the single numbers or not, and searching the first database if the number of the generated single numbers does not meet the request for generating the single numbers; if the newly generated single number is found in the first database, generating a new single number according to the newly generated single number; and if the maximum variable is not found in the first database, generating a new single number according to the maximum variable stored in the first database or the second database.
6. The method of claim 1 or 2, wherein the first database is an in-memory database and the second database is a relational database.
7. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
8. An electronic device, comprising:
one or more processors;
memory for storing one or more computer programs that, when executed by the one or more processors, cause the electronic device to implement the method of any of claims 1-6.
CN201811541767.XA 2018-12-17 2018-12-17 Method, medium, and electronic device for generating a single number in a computer system Active CN109670975B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811541767.XA CN109670975B (en) 2018-12-17 2018-12-17 Method, medium, and electronic device for generating a single number in a computer system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811541767.XA CN109670975B (en) 2018-12-17 2018-12-17 Method, medium, and electronic device for generating a single number in a computer system

Publications (2)

Publication Number Publication Date
CN109670975A CN109670975A (en) 2019-04-23
CN109670975B true CN109670975B (en) 2021-02-05

Family

ID=66144516

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811541767.XA Active CN109670975B (en) 2018-12-17 2018-12-17 Method, medium, and electronic device for generating a single number in a computer system

Country Status (1)

Country Link
CN (1) CN109670975B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111210299B (en) * 2019-12-25 2024-04-19 深圳猛犸电动科技有限公司 Single number generation and management method and device
CN111353773B (en) * 2020-02-24 2024-01-16 网银在线(北京)科技有限公司 Identification processing method and device, storage medium and electronic device
CN111353772B (en) * 2020-02-24 2024-01-16 网银在线(北京)科技有限公司 Single number generation method and device, storage medium and electronic device
CN112925851B (en) * 2021-02-26 2023-06-13 杭州网易再顾科技有限公司 Single number processing method and device, electronic equipment and storage medium
CN113313540B (en) * 2021-08-02 2021-09-28 云账户技术(天津)有限公司 Contract generation method and device, electronic equipment and readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102646121A (en) * 2012-02-23 2012-08-22 武汉大学 Two-stage storage method combined with RDBMS (relational database management system) and Hadoop cloud storage
CN104484136A (en) * 2014-12-25 2015-04-01 深圳联友科技有限公司 Method capable of supporting high-concurrency memory data
CN108460041A (en) * 2017-02-20 2018-08-28 腾讯科技(深圳)有限公司 The treating method and apparatus of data

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222107A (en) * 2011-06-28 2011-10-19 中国联合网络通信集团有限公司 Data access system and method
CN105550366B (en) * 2016-01-20 2019-10-18 百度在线网络技术(北京)有限公司 Inventory information treating method and apparatus
CN108428182B (en) * 2017-06-25 2021-08-24 平安科技(深圳)有限公司 Development platform device, method for acquiring policy number, and computer-readable storage medium
CN108874903A (en) * 2018-05-24 2018-11-23 中国平安人寿保险股份有限公司 Method for reading data, device, computer equipment and computer readable storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102646121A (en) * 2012-02-23 2012-08-22 武汉大学 Two-stage storage method combined with RDBMS (relational database management system) and Hadoop cloud storage
CN104484136A (en) * 2014-12-25 2015-04-01 深圳联友科技有限公司 Method capable of supporting high-concurrency memory data
CN108460041A (en) * 2017-02-20 2018-08-28 腾讯科技(深圳)有限公司 The treating method and apparatus of data

Also Published As

Publication number Publication date
CN109670975A (en) 2019-04-23

Similar Documents

Publication Publication Date Title
CN109670975B (en) Method, medium, and electronic device for generating a single number in a computer system
CN109271450B (en) Database synchronization method, device, server and storage medium
US11080260B2 (en) Concurrent reads and inserts into a data structure without latching or waiting by readers
US7890541B2 (en) Partition by growth table space
US9916313B2 (en) Mapping of extensible datasets to relational database schemas
US10552378B2 (en) Dividing a dataset into sub-datasets having a subset of values of an attribute of the dataset
CN109271343B (en) Data merging method and device applied to key value storage system
CN111258966A (en) Data deduplication method, device, equipment and storage medium
CN103678556A (en) Method for processing column-oriented database and processing equipment
US11593375B2 (en) Dashboard loading from a cloud-based data warehouse cache
CN109690522B (en) Data updating method and device based on B+ tree index and storage device
US10664460B2 (en) Index B-tree maintenance for linear sequential insertion
CN107408132B (en) Method and system for moving hierarchical data objects across multiple types of storage
US20200233799A1 (en) Method, apparatus, and computer program product for managing storage system
US11860873B2 (en) Dashboard loading using a filtering query from a cloud-based data warehouse cache
US20230043307A1 (en) Replicating Changes Written by a Transactional Virtual Storage Access Method
CN114579617A (en) Data query method and device, computer equipment and storage medium
CN113486023A (en) Database and table dividing method and device
US10860558B2 (en) Techniques for managing index structures for database tables
CN113515504B (en) Data management method, device, electronic equipment and storage medium
JP7293544B2 (en) Q&A system update processing method and device
US11347406B2 (en) Method, electronic device and computer program product for updating information
CN114595237A (en) Data double-writing method and device
CN116955364A (en) Block chain-based data storage method, equipment and storage medium
CN117033480A (en) Database writing method and device, electronic equipment and storage medium

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