Search

CN-122019539-A - Sequence identification generation method, device, equipment, medium and program product

CN122019539ACN 122019539 ACN122019539 ACN 122019539ACN-122019539-A

Abstract

The application provides a sequence identification generation method which can be applied to the technical field of computers. The method includes the steps of sending a number segment acquisition request for at least one first number segment to a database, wherein each first number segment comprises a plurality of serial numbers, receiving at least one first number segment allocated by the database based on the number segment acquisition request, storing the at least one first number segment in a target number Duan Chi in a memory of a server, determining a target serial number from the at least one first number segment in the target number Duan Chi in response to receiving newly added first service data, allocating the target serial number to the first service data, and storing the first service data in the database based on the target serial number. The application also provides a sequence identifier generating device, equipment, a storage medium and a program product.

Inventors

  • JING FEI

Assignees

  • 中国工商银行股份有限公司

Dates

Publication Date
20260512
Application Date
20260123

Claims (11)

  1. 1. A method for generating a sequence identifier, wherein the method is applied to a plurality of distributed servers in data communication with a database, the method comprising: transmitting a number segment acquisition request for at least one first number segment to the database, wherein each first number segment comprises a plurality of serial numbers; Receiving the at least one first number segment allocated by the database based on the number segment acquisition request, and storing the at least one first number segment in a target number Duan Chi in a memory of a server; determining a target sequence number from at least one first number segment in the target number Duan Chi in response to receiving the newly added first service data; And allocating the target serial number to the first service data, and storing the first service data into the database based on the target serial number.
  2. 2. The method of claim 1, wherein the target number segment pool includes a primary number Duan Chi and a backup number Duan Chi, and the storing the at least one first number segment in the target number Duan Chi in the memory of the server includes: And dispersing and storing a plurality of serial numbers in the at least one first number segment into the primary number Duan Chi and the spare number segment pool.
  3. 3. The method according to claim 2, wherein the method further comprises: And when the serial numbers in the main number Duan Chi are allocated and the serial numbers with the first number ratio in the serial numbers in the spare number segment pool are allocated, sending an acquisition request for a second number segment to the database, and storing the second number segment into the main number Duan Chi.
  4. 4. The method of claim 1, wherein the target number segment pool includes a primary number Duan Chi and a backup number Duan Chi, and the storing the at least one first number segment in the target number Duan Chi in the memory of the server includes: storing all of the plurality of sequence numbers in the at least one first number segment into the main number Duan Chi; the method further comprises the steps of: And sending an acquisition request for a third number segment to the database and storing the third number segment into the spare number segment pool under the condition that the sequence numbers with the second number ratio in the sequence numbers in the main number Duan Chi are allocated.
  5. 5. The method of claim 1, wherein the number segment acquisition request for at least one first number segment comprises a target number segment step size, the target number segment step size being determined by: Acquiring a historical number segment consumption rate, and determining a consumption number segment step length based on the historical number segment consumption rate, a preset reference rate, a preset basic step length and a preset buffer parameter; Determining the target number segment step length from a preset first step length, a preset second step length and the consumption number segment step length, wherein the preset first step length is larger than the preset second step length.
  6. 6. The method of claim 2, wherein the determining the target number segment step from a preset first step size, a preset second step size, and the consumption number segment step size comprises: Determining a candidate number segment step length from the consumption number segment step length and the preset second step length, wherein the candidate number segment step length is a larger step length in the consumption number segment step length and the preset second step length; And determining the target number segment step length from the candidate number segment step length and the preset first step length, wherein the target number segment step length is the smaller step length of the candidate number segment step length and the preset first step length.
  7. 7. The method of claim 1, further comprising, after said determining a target sequence number from at least a first number segment of said target number Duan Chi: acquiring a first time stamp corresponding to the new time of the first service data, and assembling the first time stamp with the target sequence number to obtain a verification sequence number; storing the verification serial number into the database; And responding to the received newly added second service data, acquiring a second time stamp corresponding to the newly added time of the second service data, and performing error reporting processing under the condition that the second time stamp is smaller than the first time stamp in the verification serial number.
  8. 8. A sequence identity generation apparatus, the apparatus being configured for a plurality of distributed servers in data communication with a database, the apparatus comprising: the sending module is used for sending a number segment acquisition request for at least one first number segment to the database, wherein each first number segment comprises a plurality of serial numbers; The receiving module is used for receiving the at least one first number segment allocated by the database based on the number segment acquisition request and storing the at least one first number segment into a target number Duan Chi in a memory of the server; A determining module, configured to determine a target sequence number from at least one first number segment in the target number Duan Chi in response to receiving the newly added first service data; And the allocation module is used for allocating the target sequence number to the first service data and storing the first service data into the database based on the target sequence number.
  9. 9. An electronic device, comprising: one or more processors; A memory for storing one or more computer programs, Characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1-7.
  10. 10. A computer-readable storage medium, on which a computer program or instructions is stored, which, when executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
  11. 11. A computer program product comprising a computer program or instructions which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.

Description

Sequence identification generation method, device, equipment, medium and program product Technical Field The present application relates to the field of computer technology, and more particularly, to a sequence identifier generating method, apparatus, device, medium, and program product. Background With the rapid development of the internet and the mobile internet, both order numbers, message identifications, device codes and link tracking identifications need to be unique in a global scope. In the related art, an empty record needs to be inserted into the database or the database self-increment is called when the service data is received every time, and the service data is written back after the database returns to the primary key. However, in the case of a large amount of service data, the method needs to access the database for many times, which results in a large database pressure. Disclosure of Invention In view of the foregoing, the present application provides a sequence identity generation method, apparatus, device, medium, and program product. According to a first aspect of the present application, there is provided a sequence identifier generating method, including sending a number segment acquisition request for at least one first number segment to the database, where each of the first number segments includes a plurality of sequence numbers, receiving the at least one first number segment allocated by the database based on the number segment acquisition request, and storing the at least one first number segment in a target number Duan Chi in a memory of a server, determining a target sequence number from the at least one first number segment in the target number Duan Chi in response to receiving newly added first service data, allocating the target sequence number to the first service data, and storing the first service data in the database based on the target sequence number. According to the embodiment of the application, the target number segment pool comprises a main number Duan Chi and a spare number Duan Chi, and the target number Duan Chi for storing the at least one first number segment in the memory of the server side comprises the step of storing a plurality of serial numbers in the at least one first number segment in a dispersed manner into the main number Duan Chi and the spare number segment pool. According to an embodiment of the present application, the method further includes sending an acquisition request for a second number segment to the database and storing the second number segment in the primary number Duan Chi when the sequence number in the primary number Duan Chi is allocated and a first number of the sequence numbers in the spare number segment pool is allocated. According to the embodiment of the application, the target number segment pool comprises a main number Duan Chi and a spare number Duan Chi, the target number Duan Chi for storing the at least one first number segment in the memory of the server side comprises the steps of storing all the plurality of serial numbers in the at least one first number segment into the main number Duan Chi, and sending an acquisition request for a third number segment to the database and storing the third number segment into the spare number segment pool when the second number of the plurality of serial numbers in the main number Duan Chi is allocated. According to the embodiment of the application, the number segment acquisition request for at least one first number segment comprises a target number segment step size, wherein the target number segment step size is determined by acquiring a history number segment consumption rate, determining a consumption number segment step size based on the history number segment consumption rate, a preset reference rate, a preset basic step size and a preset buffer parameter, and determining the target number segment step size from a preset first step size, a preset second step size and the consumption number segment step size, wherein the preset first step size is larger than the preset second step size. According to the embodiment of the application, the target number segment step length is determined from a preset first step length, a preset second step length and the consumption number segment step length, and the target number segment step length comprises the step of determining a candidate number segment step length from the consumption number segment step length and the preset second step length, wherein the candidate number segment step length is the larger step length of the consumption number segment step length and the preset second step length, the step of determining the target number segment step length from the candidate number segment step length and the preset first step length, and the target number segment step length is the smaller step length of the candidate number segment step length and the preset first step length. According to the embodiment of the application, after