Sequence number generation method, device and equipment of distributed system and storage medium
By receiving business scenario and location information to determine the target sequence number template table, generating and storing sequence numbers, the problem of high sequence number generation and maintenance costs in distributed systems is solved, and efficient sequence number generation and management are achieved.
Patent Information
- Application Number
- CN202310799319.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2043-06-30
AI Technical Summary
In high-concurrency scenarios, the maintenance cost and efficiency of sequence number generation in distributed systems are high. Existing technologies require modifying the sequence number generator one by one, resulting in high manpower and time costs.
By receiving business scenario information and request location information from the serial number generation instruction, the target serial number template table is determined, and the generation table is matched with the associated serial number generation table to generate and store serial numbers. It supports batch modification and maintenance of the serial number generation table and uses caching to improve the number retrieval speed.
It enables differentiation and management of serial number generation methods in various business scenarios, improving maintainability and retrieval speed, and reducing maintenance costs.
Smart Images

Figure CN116860749B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of distributed system technology, and in particular to a method, apparatus, device, and storage medium for generating serial numbers in a distributed system. Background Technology
[0002] Currently, the main solution to the serial number generation needs of business systems in high-concurrency scenarios is to deploy the serial number generator in a distributed system, so that the distributed system can quickly and accurately generate the corresponding serial numbers for the serial number generation needs of each business system.
[0003] With the development of computer technology, business systems are becoming increasingly feature-rich, leading to a growing demand for game number generation tools. Consequently, the number of game number generators corresponding to these demands is also increasing. Therefore, when the game number generation requirements of a business system change, efficiently modifying and maintaining the corresponding game number generators based on these changing requirements becomes a pressing issue.
[0004] In related technologies, the main approach is to modify the number generators corresponding to each number generation requirement one by one. This method requires significant manpower and time costs, resulting in high maintenance costs and low maintenance efficiency. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for generating serial numbers in a distributed system, in order to solve the problems of high maintenance cost and low maintenance efficiency of serial numbers in a distributed system.
[0006] Firstly, this application provides a method for generating sequence numbers in a distributed system, including:
[0007] Receive a sequence number generation instruction; wherein the sequence number generation instruction includes business scenario information and request location information; the business scenario information indicates the business scenario in which the sequence number is applied, and the request location information indicates the source location of the sequence number generation instruction;
[0008] Based on the business scenario information, a target sequence number template table is determined, and a target sequence number generation table that matches the request location information is determined from at least one sequence number generation table associated with the target sequence number template table; wherein, the sequence number template table indicates the sequence number generation method in the corresponding business scenario, and the sequence number generation table indicates the sequence number generation method corresponding to the source location of the sequence number generation instruction.
[0009] A serial number is generated based on the serial number generation method indicated by the target serial number generation table, and the generated serial number is stored in the cache.
[0010] In one example, the method further includes:
[0011] If no sequence number generation table matching the requested location information is determined from at least one sequence number generation table associated with the target sequence number template table, a new sequence number generation table matching the requested location information is created based on the target sequence number template table, and an association relationship is established between the new sequence number generation table and the target sequence number template table.
[0012] In one example, the target serial number generation table contains first serial number generation configuration data; the first serial number generation configuration data includes at least a serial number generation range, a serial number generation mode, and a serial number generation quantity; the serial number generation mode indicates the association relationship between adjacent generated serial numbers;
[0013] The step of generating a serial number based on the serial number generation method indicated by the target serial number generation table and storing the generated serial number in the cache includes:
[0014] Within the specified number generation range, generate a number of serial numbers according to the specified number generation mode, and store the specified number of serial numbers in the cache.
[0015] In one example, the target sequence number template table includes second sequence number generation configuration data; the second sequence number generation configuration data is used to determine the sequence number generation method in the corresponding business scenario; the first sequence number generation configuration data is the same as the second sequence number generation configuration data.
[0016] The method further includes:
[0017] After detecting an edit operation on any second serial number generation configuration data in the target serial number template table, first configuration data editing information is obtained, and the second serial number generation configuration data in the target serial number template table is updated based on the first configuration data editing information, as well as the first serial number generation configuration data in each serial number generation table associated with the target serial number template table is updated.
[0018] In one example, the method further includes:
[0019] After detecting an edit operation on the configuration data of any first serial number in the serial number generation table, the system obtains the second configuration data edit information and updates the first serial number generation configuration data in the serial number generation table based on the second configuration data edit information.
[0020] In one example, after generating a serial number based on the serial number generation method indicated by the target serial number generation table and storing the generated serial number in a cache, the method further includes:
[0021] In response to the client's sequence number retrieval command, determine the sequence number that matches the sequence number retrieval command from the cache;
[0022] Based on the remaining serial numbers in the cache excluding the matching serial number, and the number of serial numbers that the target serial number generation table can generate, the serial number usage information is determined;
[0023] The matching serial number and the serial number usage information are returned to the client.
[0024] In one example, the method further includes:
[0025] If the target sequence number template table cannot be determined based on the business scenario information, the target sequence number generation table is determined from at least one separate sequence number generation table based on the request location information, and a sequence number is generated based on the sequence number generation method indicated by the target sequence number generation table; wherein, the separate sequence number generation table indicates a sequence number generation table that has not been associated with any sequence number template table.
[0026] In one example, the method further includes:
[0027] In response to a deletion operation on the serial number template table, a deletion operation is performed on the serial number template table and each serial number generation table associated with the serial number template table.
[0028] In one example, the method further includes:
[0029] In response to a serial number recycling instruction, determine the serial number to be recycled as indicated by the serial number recycling instruction;
[0030] If a serial number is found in the cache that is the same as the serial number to be reclaimed as indicated by the serial number reclamation instruction, the same serial number is added to the database and deleted from the cache.
[0031] Secondly, this application provides a sequence number generation device for a distributed system, comprising:
[0032] A receiving unit is configured to receive a sequence number generation instruction; wherein the sequence number generation instruction includes business scenario information and request location information; the business scenario information indicates the business scenario in which the sequence number is applied, and the request location information indicates the source location of the sequence number generation instruction;
[0033] The determining unit is configured to determine a target sequence number template table based on the business scenario information, and to determine a target sequence number generation table that matches the request location information from at least one sequence number generation table associated with the target sequence number template table; wherein, the sequence number template table indicates the sequence number generation method in the corresponding business scenario, and the sequence number generation table indicates the sequence number generation method corresponding to the source location of the sequence number generation instruction.
[0034] The generation unit is used to generate a serial number based on the serial number generation method indicated by the target serial number generation table, and store the generated serial number in the cache.
[0035] In one example, determining the unit also includes:
[0036] A creation module is configured to, when no sequence generation table matching the requested location information is determined from at least one sequence generation table associated with the target sequence template table, create a new sequence generation table matching the requested location information based on the target sequence template table, and establish an association between the new sequence generation table and the target sequence template table.
[0037] In one example, the target serial number generation table contains first serial number generation configuration data; the first serial number generation configuration data includes at least a serial number generation range, a serial number generation mode, and a serial number generation quantity; the serial number generation mode indicates the association relationship between adjacent generated serial numbers.
[0038] The generating unit is also used for:
[0039] Within the specified number generation range, generate a number of serial numbers according to the specified number generation mode, and store the specified number of serial numbers in the cache.
[0040] In one example, the target serial number template table includes second serial number generation configuration data; the second serial number generation configuration data is used to determine the serial number generation method in the corresponding business scenario; the first serial number generation configuration data is the same as the second serial number generation configuration data.
[0041] The determining unit also includes:
[0042] The editing module is configured to, upon detecting an editing operation on the configuration data for generating any second serial number in the target serial number template table, acquire first configuration data editing information, update the configuration data for generating the second serial number in the target serial number template table based on the first configuration data editing information, and update the configuration data for generating the first serial number in each serial number generation table associated with the target serial number template table.
[0043] In one example, the edit module is also used for:
[0044] After detecting an edit operation on the configuration data of any first serial number in the serial number generation table, the system obtains the second configuration data edit information and updates the first serial number generation configuration data in the serial number generation table based on the second configuration data edit information.
[0045] In one example, the device also includes:
[0046] The serial number recycling module is used to generate serial numbers based on the serial number generation method indicated by the target serial number generation table, and after storing the generated serial numbers in the cache, in response to the serial number retrieval instruction from the client, determine the serial number that matches the serial number retrieval instruction from the cache.
[0047] Based on the remaining serial numbers in the cache excluding the matching serial number, and the number of serial numbers that the target serial number generation table can generate, the serial number usage information is determined;
[0048] The matching serial number and the serial number usage information are returned to the client.
[0049] In one example, the device is also used for:
[0050] If the target sequence number template table cannot be determined based on the business scenario information, the target sequence number generation table is determined from at least one separate sequence number generation table based on the request location information, and a sequence number is generated based on the sequence number generation method indicated by the target sequence number generation table; wherein, the separate sequence number generation table indicates a sequence number generation table that has not been associated with any sequence number template table.
[0051] In one example, the device is also used for:
[0052] In response to a deletion operation on the serial number template table, a deletion operation is performed on the serial number template table and each serial number generation table associated with the serial number template table.
[0053] In one example, the device also includes:
[0054] The serial number recycling module is used to respond to the serial number recycling command and determine the serial number to be recycled as indicated by the serial number recycling command;
[0055] If a serial number is found in the cache that is the same as the serial number to be reclaimed as indicated by the serial number reclamation instruction, the same serial number is added to the database and deleted from the cache.
[0056] Thirdly, this application provides a computer device, including: a processor, and a memory communicatively connected to the processor;
[0057] The memory stores instructions that the computer executes;
[0058] The processor executes computer execution instructions stored in memory to implement the method described in the first aspect above.
[0059] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect above.
[0060] Fifthly, this application provides a computer program product comprising: computer execution instructions stored in a readable storage medium, wherein at least one processor of a computer device can read the computer execution instructions from the readable storage medium, and the at least one processor executes the computer execution instructions to cause the computer device to perform the method described in the first aspect.
[0061] The serial number generation method, apparatus, device, and storage medium for distributed systems provided in this application can determine a target serial number template table based on the business scenario information in the serial number generation instruction after receiving it. This allows for accurate determination of the serial number generation method matching the business scenario. At this point, the serial number template table can be used to differentiate and manage the serial number generation methods under various business scenarios. Multiple serial number generation tables can be modified or maintained in batches using the target serial number template table, making the serial number generation tables under each business scenario more ordered and maintainable. Subsequently, a target serial number generation table can be determined from at least one serial number generation table associated with the target serial number template table, and serial numbers can be generated based on the serial number generation method indicated by the target serial number generation table. This allows for differentiation of serial numbers from different source locations within a unified business scenario, enabling the generation of corresponding serial numbers for serial number generation instructions from each source location. Finally, the generated serial numbers can be stored in a cache. Upon receiving a serial number retrieval request, the corresponding serial number can be retrieved from the cache, thereby improving the serial number retrieval speed. Attached Figure Description
[0062] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0063] Figure 1 A flowchart illustrating a method for generating sequence numbers in a distributed system, as provided in an embodiment of this application;
[0064] Figure 2 A flowchart illustrating another method for generating serial numbers in a distributed system provided in this application embodiment;
[0065] Figure 3 A schematic diagram of an editing page for a pre-set serial number template table provided in an embodiment of this application;
[0066] Figure 4 A schematic diagram of a pre-set serial number generation table provided for an embodiment of this application;
[0067] Figure 5This is a schematic diagram of a service cluster provided in an embodiment of this application;
[0068] Figure 6 A schematic diagram of the structure of a serial number generation device for a distributed system provided in an embodiment of this application;
[0069] Figure 7 A schematic diagram of the structure of another serial number generation device for a distributed system provided in an embodiment of this application;
[0070] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of this application;
[0071] Figure 9 This is a block diagram illustrating a computer device according to an exemplary embodiment.
[0072] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0073] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0074] It should be noted that the serial number generation method, apparatus, device, and storage medium for distributed systems provided in this application can be used in the field of distributed system technology, as well as in any data processing technology field other than the field of distributed system technology. The application fields of the serial number generation method, apparatus, device, and storage medium for distributed systems provided in this application are not limited here.
[0075] As the functionality of the business system increases, so does the demand for number issuance. Each demand can be matched with a number issuer to distribute the required serial numbers. If the demand changes, the corresponding number issuer can be modified to meet the altered requirements.
[0076] For example, if multiple key issuance requests all request serial numbers containing the target content, and if the target content of the requested serial numbers changes, the key issuers corresponding to these multiple key issuance requests need to be modified so that the serial numbers distributed by the key issuers can meet the changed key issuance requests. In this case, if there are many key issuance requests containing the target content, the key issuers corresponding to multiple key issuance requests need to be modified and maintained in batches. Modifying the key issuers one by one results in a large workload and high maintenance costs.
[0077] The data transmission method provided in this application is intended to solve the above-mentioned technical problems of the prior art.
[0078] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0079] Figure 1 This is a flowchart illustrating a method for generating sequence numbers in a distributed system, as provided in an embodiment of this application. Figure 1 As shown, the method includes:
[0080] S101, Receive sequence number generation instruction.
[0081] The sequence number generation instruction includes business scenario information and request location information; the business scenario information indicates the business scenario in which the sequence number is applied, and the request location information indicates the source location of the sequence number generation instruction.
[0082] In this embodiment of the application, when a unique ID (Identity Document) serial number is required in a business scenario, a serial number generation instruction can be initiated. The server can receive the serial number generation instruction and obtain the serial number based on the serial number generation instruction.
[0083] In one example, business scenario information could be "transaction number", "order number", "credit card number", "application number", etc.
[0084] In one example, the requested location information could be "Location 1" or "Merchant A", etc.
[0085] Here, one business scenario information can correspond to multiple request location information, and one request location information can also correspond to multiple business scenarios.
[0086] For example, assuming that the business scenario information is a "serial number", the request location information corresponding to the business scenario information "serial number" can be "site 1", "site 2" and "site 3".
[0087] If the requested location information is "Branch 1", then the corresponding business scenario information can be "Transaction Number", "Order Number" and "Credit Card Number".
[0088] S102. Determine the target sequence number template table based on the business scenario information, and determine the target sequence number generation table that matches the requested location information from at least one sequence number generation table associated with the target sequence number template table.
[0089] The sequence number template table indicates the sequence number generation method in the corresponding business scenario, and the sequence number generation table indicates the sequence number generation method corresponding to the source location of the sequence number generation instruction.
[0090] In this embodiment of the application, one or more sequence number template tables can be set in advance in the server. Each sequence number template table can be used to indicate the sequence number generation method under the business scenario indicated by the corresponding business scenario information.
[0091] Each sequence number template table can be associated with at least one sequence number generation table. In this case, the sequence number generation table can be understood as a sequence number generation method that matches the source location of the sequence number generation instruction indicated by the request location information under the business scenario indicated by the corresponding business scenario information.
[0092] Then, the target sequence number template table can be determined from one or more pre-set sequence number template tables based on the business scenario information in the sequence number generation instruction.
[0093] In one example, this embodiment of the application can set corresponding sequence template identifiers for each sequence template table based on various business scenario information. Then, the target template table can be determined by the sequence template identifier that matches the business scenario information in the sequence number generation instruction. The content of the sequence template identifier in the target template table can be the same as or correspond to the content of the business scenario information.
[0094] In one example, after the target template table is determined, a target sequence number generation table that matches the requested location information in the sequence number generation instruction can be determined from at least one sequence number generation table associated with the target template table.
[0095] Specifically, a corresponding generation table identifier can be set for each sequence number generation table based on the requested location information, and the target sequence number generation table can be determined based on the generation table identifier that matches the requested location information in the sequence number generation instruction.
[0096] In addition to including the source location of the sequence number generation instruction indicated by the request location information, the generation table identifier of each sequence number generation table can also include other information corresponding to the sequence number generation instruction. For example, other information corresponding to the sequence number generation instruction can be the product name (or project name) that initiated the sequence number generation instruction in the corresponding business scenario. For example, the product name can be "Graduation Season Credit Card" or "Test Project", etc.
[0097] It should be noted that if the sequence number template table is not associated with the sequence number generation table, a new sequence number generation table can be created after receiving the sequence number generation instruction, based on the request location information contained in the sequence number generation instruction and the sequence number generation method indicated by the sequence number template table in the corresponding business scenario.
[0098] S103. Generate a serial number based on the serial number generation method indicated by the target serial number generation table, and store the generated serial number in the cache.
[0099] The serial number generation method, apparatus, device, and storage medium for a distributed system provided in this application can determine a target serial number template table based on the business scenario information in the serial number generation instruction after receiving the instruction. This allows for accurate determination of the serial number generation method matching the business scenario. The target serial number template table can be used to differentiate and manage the serial number generation methods under various business scenarios. Multiple serial number generation tables can be modified or maintained in batches using the target serial number template table, making the serial number generation tables under each business scenario more orderly and maintainable. Subsequently, a target serial number generation table can be determined from at least one serial number generation table associated with the target serial number template table, and serial numbers can be generated based on the serial number generation method indicated by the target serial number generation table. This allows for differentiation of serial numbers from different source locations within a unified business scenario, enabling the generation of corresponding serial numbers for serial number generation instructions from each source location. Finally, the generated serial numbers can be stored in a cache. Upon receiving a serial number retrieval request, the corresponding serial number can be retrieved from the cache, thereby improving the retrieval speed.
[0100] Figure 2 This is a flowchart illustrating another method for generating sequence numbers in a distributed system, provided in an embodiment of this application. For example... Figure 2 As shown, the method includes:
[0101] S201, Receive sequence number generation instruction.
[0102] The sequence number generation instruction includes business scenario information and request location information; the business scenario information indicates the business scenario in which the sequence number is applied, and the request location information indicates the source location of the sequence number generation instruction.
[0103] For example, this step can be referred to step S101, which will not be repeated here.
[0104] S202. Determine the target sequence number template table based on the business scenario information, and determine the target sequence number generation table that matches the requested location information from at least one sequence number generation table associated with the target sequence number template table.
[0105] The sequence number template table indicates the sequence number generation method in the corresponding business scenario, and the sequence number generation table indicates the sequence number generation method corresponding to the source location of the sequence number generation instruction.
[0106] In one example, the sequence number template table can contain at least a sequence number template identifier and sequence number generation configuration data. The sequence number template identifier is used to distinguish different sequence number template tables; for example, the sequence number template identifier can be the set sequence number template name, which is the same as or corresponds to the business scenario information.
[0107] In one example, the serial number template identifier can include not only the template name but also the product name. For example, the product name can be the name of the product (or project) to which the serial number generation instruction belongs in the corresponding business scenario. For example, the product name can be "Graduation Season Credit Card" or "Test Project".
[0108] For example, Figure 3 This is a schematic diagram of an editing page for a pre-set serial number template table provided in an embodiment of this application. When pre-setting the serial number template table, the serial number template identifier and serial number generation configuration data (i.e., the second serial number generation configuration data hereinafter referred to as the serial number template table) contained in the serial number template table can be edited on the editing page of the serial number template table, and the created serial number template table is obtained after editing.
[0109] like Figure 3 As shown, when a serial number template table is pre-set, the content that can be set includes at least the following: product name, serial number type (here, serial number type is used to indicate whether the currently created table is a serial number template table or a serial number generation table, for example, ...). Figure 3 As shown, when a serial number template is selected, it indicates the creation of a serial number template table, serial number type, serial number template name, serial number cycle type, and minimum serial number value (i.e., ...). Figure 3 The minimum value in the sequence), the maximum value of the sequence number (that is, Figure 3 The maximum value in the table), step size, and number of generated serial numbers, etc. Among these, the product name, serial number type, and serial number template name can be understood as the serial number template identifier of the serial number template table, the serial number type, the serial number cycle type, and the minimum serial number value (i.e., Figure 3 The minimum value in the sequence), the maximum value of the sequence number (that is, Figure 3The maximum value, step size, and number of serial numbers generated can be understood as the serial number generation configuration data of the serial number template table.
[0110] The step size indicates the number of serial numbers that can be retrieved at once during the retrieval process, as determined by the serial number generation method corresponding to the serial number template table. For example, with a step size of 5, upon receiving a retrieval request for serial numbers generated by the serial number template table, 5 serial numbers can be retrieved from the cache and returned to the requesting party at once. The number of serial numbers generated can be understood as the number of serial numbers that can be stored in the cache at once, as determined by the serial number generation method corresponding to the serial number template table. For example, if the number of serial numbers generated is 100, it means that the serial number generation method corresponding to the serial number template table can generate 100 serial numbers at once after receiving a serial number generation instruction and store these 100 serial numbers in the cache.
[0111] In addition, such as Figure 3 As shown, when creating a serial number template table, corresponding remarks can also be set for the serial number template table, which can help staff understand the relevant information of the current serial number template table more quickly and accurately.
[0112] For example, the set serial number template table can be as follows: Figure 3 As shown, you can set the product name to "A", the serial number type to "serial number template", the serial number type to "random serial number", the serial number template name to "serial number", the serial number cycle type to "non-repeating", the minimum serial number value to "1", and the maximum serial number value to "999" (at this time, the minimum and maximum values are...). Figure 3 The sequence number template table is set as follows: 1-999, step size is "1", number of generated serial numbers is "100", and remarks are "none". After clicking OK, the serial number template table will be set.
[0113] In one example, after setting up the serial number template table, you can also manage the pre-set serial number template tables. The operations for managing the pre-set serial number template tables can be any of the following: editing, viewing, or deleting.
[0114] The edit operation can be used to modify the contents of the serial number template table (such as the serial number template identifier and serial number generation configuration data); the view operation can be used to view the contents of the serial number template table; and the delete operation can indicate the deletion of the serial number template table.
[0115] In one example, the sequence number generation table can at least contain a generation table identifier and sequence number generation configuration data (i.e., the first sequence number generation configuration data described below). The generation table identifier is used to distinguish each sequence number generation table. For example, the generation table identifier can be a set sequence number name, which is the same as or corresponds to the source location of the sequence number generation instruction. For example, the sequence number name can be the same as the requested location information, such as "Network Point 1". Alternatively, the sequence number name can correspond to the requested location information, such as the identifier information "1" corresponding to "Network Point 1". In addition, the sequence number generation table can also contain a product name, in which case the product name is the same as or corresponds to the name of the product or project to which the sequence number generation instruction belongs. For example, the product name can be the name of the product to which the sequence number generation instruction belongs, "Product 1", or the product name can be the name of the project to which the sequence number generation instruction belongs, "Test Project", etc.
[0116] In this embodiment of the application, multiple serial number generation tables can be pre-set and associated with each serial number generation table with a serial number template table. Alternatively, the multiple serial number generation tables can also be independent serial number generation tables, not associated with any serial number template table.
[0117] In one example, Figure 4 This is a schematic diagram of a pre-set serial number generation table provided in an embodiment of this application. For example... Figure 4 As shown, the number of pre-set serial number generation tables can be two, and each serial number generation table contains a generation table identifier of product name and serial number name. The serial number generation configuration data contained in each serial number generation table includes serial number type, loop type, and minimum serial number value (i.e., ...). Figure 4 The minimum value shown), the maximum value of the sequence number (that is, Figure 4 The first serial number generation table can contain: product name "A", serial number name "1", serial number type "random serial number", loop type "non-looping", minimum serial number value "1", maximum serial number value "999", step size "1", and serial number generation quantity "100"; the second serial number generation table can contain: product name "A", serial number name "123", serial number type "incrementing serial number", loop type "looping", minimum serial number value "1", maximum serial number value "99999", step size "1", and serial number generation quantity "100".
[0118] In one example, after setting up the serial number generation table, you can also manage the pre-defined serial number generation tables. For example, such as... Figure 4 As shown, the operations for managing the pre-set serial number generation tables can be any of the following: editing, viewing, or deleting.
[0119] The edit operation can be used to modify the contents of the serial number generation table (e.g., the generation table identifier and serial number generation configuration data); the view operation can be used to view the generation status of serial numbers under the serial number generation table, or to view the usage status of serial numbers under the serial number generation table; the delete operation can indicate the deletion of the serial number generation table.
[0120] In one example, such as Figure 4 As shown, the availability of each pre-set sequence number generation table can also be configured. For example, the status of the first sequence number generation table shown in Figure 4 can be set to "available," meaning that sequence numbers can be generated based on the sequence numbers in the first table. Conversely, the status of the second sequence number generation table shown in Figure 4 can be set to "unavailable," meaning that sequence numbers cannot be generated based on the sequence numbers in the first table.
[0121] In one example, the association between the serial number generation table and the serial number template table can be established through the template name (i.e., the serial number template name). For example, as shown below... Figure 4 As shown, the serial number template table associated with these two serial number generation tables has the template name (i.e., the serial number template name) as "serial number".
[0122] In one example, after setting up the serial number generation table, when you need to search for the serial number generation table, you can search for at least one of the following: product name, serial number type, serial number name, and template name. For example, such as... Figure 4 As shown, when searching for the serial number generation table with product name "A" and template name "Serial Number", clicking the query button yields the following results: Figure 4 The two serial number generation tables are shown.
[0123] In this embodiment of the application, after determining the target serial number template table and the target serial number generation table, serial numbers can be generated according to the serial number generation method indicated by the target serial number generation table.
[0124] In one example, the process of determining the target sequence number template table and the target sequence number generation table may also include the following two sub-steps.
[0125] The first sub-step of S202 is as follows: if no sequence number generation table matching the requested location information is determined from at least one sequence number generation table associated with the target sequence number template table, a new sequence number generation table matching the requested location information is created based on the target sequence number template table, and an association relationship is established between the new sequence number generation table and the target sequence number template table.
[0126] Specifically, the generation table identifier of the new sequence number generation table can be determined based on the requested location information, and the sequence number generation configuration data of the new sequence number generation table can be determined based on the sequence number generation configuration data contained in the target sequence number template, thus obtaining the new sequence number generation table.
[0127] Then, the new serial number generation table can be associated with the target serial number template table by adding the target serial number template identifier information of the target serial number template table.
[0128] In the above method, if the target sequence number template table does not contain a sequence number generation table matching the requested location information, a new sequence number generation table can be generated based on the requested location information in the sequence number generation instruction. This allows for the automatic and rapid creation of a sequence number generation table matching the instruction, improving the efficiency and automation of sequence number generation table creation. Furthermore, after creating the new sequence number generation table, it can be associated with the target template table, allowing for categorization and convenient management.
[0129] The second sub-step of S202 is as follows: if the target sequence number template table is not determined based on the business scenario information, determine the target sequence number generation table from at least one separate sequence number generation table based on the request location information, and generate a sequence number based on the sequence number generation method indicated by the target sequence number generation table.
[0130] Among them, a separate sequence number generation table indicates a sequence number generation table that is not associated with any sequence number template table.
[0131] In one example, a generation table identifier that is the same as or corresponds to the requested location information can be determined from the generation table identifiers contained in each individual sequence number generation table. Then, the sequence number generation table corresponding to the same or corresponding generation table identifier can be determined as the target sequence number generation table.
[0132] In one example, if no target sequence number generation table matching the sequence number generation instruction is determined from at least one individual sequence number generation table, a request error message can be generated and returned to the end that initiated the sequence number generation instruction.
[0133] In the above embodiments, the target sequence number generation table that matches the sequence number generation instruction can be determined more comprehensively and fully, thereby further ensuring the response to the received sequence number generation instruction and improving the response probability of the sequence number generation instruction.
[0134] In one example, the target sequence number generation table contains first sequence number generation configuration data; the first sequence number generation configuration data includes at least the sequence number generation range, the sequence number generation mode, and the sequence number generation quantity; the sequence number generation mode indicates the association relationship between adjacent generated sequences.
[0135] For example, the sequence number generation range can be determined by the minimum and maximum sequence number values. For instance, if the minimum sequence number is 1 and the maximum sequence number is 999, then the sequence number generation range formed by the minimum and maximum sequence number values is 1-999. Alternatively, the sequence number generation range can also be determined by including the minimum (or maximum) sequence number value and the size of the sequence number generation interval. For example, if the minimum sequence number is 1 and the size of the sequence number generation interval is 10000, then the sequence number generation range determined by the minimum sequence number value and the size of the sequence number generation interval is 1-9999. Similarly, for example, if the maximum sequence number is 9999 and the size of the sequence number generation interval is 10000, then the sequence number generation range determined by the maximum sequence number value and the size of the sequence number generation interval is 1-9999. This application embodiment does not specifically limit the content included in the sequence number generation range; the range that can be determined is the standard.
[0136] In one example, the number generation pattern can indicate an increasing relationship between adjacent numbers within the number generation range, thus identifying the number generation pattern as an increasing pattern. Alternatively, the number generation pattern can indicate a random relationship between adjacent numbers within the number generation range, thus identifying the number generation pattern as a random pattern. Or, the number generation pattern can also indicate a cyclically increasing relationship between adjacent numbers within the number generation range, thus identifying the number generation pattern as a cyclically increasing pattern. Or, the number generation pattern can also indicate a non-cyclically increasing relationship between adjacent numbers within the number generation range, thus identifying the number generation pattern as a non-cyclically increasing pattern.
[0137] In one example, the number of serial numbers generated can indicate the number of serial numbers generated after each serial number generation instruction is received. For example, if the number of serial numbers generated is 100, then the number of serial numbers generated after receiving the serial number generation instruction will be 100. At this time, these 100 serial numbers can be stored in the cache.
[0138] Based on this, the embodiments of this application further include the following step S203.
[0139] S203. Generate a number of serial numbers within the serial number generation range according to the serial number generation mode, and store the number of serial numbers in the cache.
[0140] In one example, if the serial number generation range is 1-999, the serial number generation mode is serial number increment mode, and the number of serial numbers generated is 100, then 100 serial numbers can be generated in an incrementing manner within the range of 1-999, and the generated serial numbers can be stored in the cache.
[0141] In one example, if the cache storing serial numbers is divided into multiple number segments, the number of serial numbers stored in the cache can be determined based on the number of number segments contained in the cache and the number of serial numbers generated. For example, if the cache storing serial numbers is divided into 2 number segments and the number of serial numbers generated is 100, then the number of generated serial numbers can be 2 * 100 = 200, and these 200 serial numbers are stored in the cache.
[0142] In one example, the target sequence number template table may include second sequence number generation configuration data; the second sequence number generation configuration data is used to determine the sequence number generation method in the corresponding business scenario; the first sequence number generation configuration data in the target sequence number generation table is the same as the second sequence number generation configuration data in the target sequence number template table. Based on this, the embodiments of this application further include the following process.
[0143] After detecting an edit operation on the configuration data of any second serial number in the target serial number template table, the system obtains the first configuration data editing information, updates the second serial number generation configuration data in the target serial number template table based on the first configuration data editing information, and updates the first serial number generation configuration data in each serial number generation table associated with the target serial number template table.
[0144] For example, if the second sequence number generation configuration data can be the sequence number type, sequence number cycle type, sequence number minimum value, sequence number maximum value, step size, and sequence number generation quantity mentioned above, then any one of the second sequence number generation configuration data items can be edited to update the target sequence number template table. For example, if the maximum sequence number value cannot meet the sequence number generation requirements, then the maximum sequence number value can be adjusted to meet the sequence number generation requirements.
[0145] Specifically, the content of the target sequence number template table can be updated by triggering an edit operation to edit the target sequence number template table.
[0146] This approach makes the target serial number template table more flexible and diverse, and can better and more conveniently meet the gradually changing serial number generation needs when the serial number generation requirements change.
[0147] In one example, where the target sequence number generation table contains the first sequence number generation configuration data, this application embodiment further includes the following process.
[0148] After detecting an edit operation on any first sequence number generated configuration data in the sequence number generation table, the second configuration data edit information is obtained, and the first sequence number generated configuration data in the sequence number generation table is updated based on the second configuration data edit information.
[0149] For example, if the first sequence number generation configuration data can be the sequence number type, loop type, minimum sequence number, maximum sequence number, step size, and number of sequence numbers generated as described above, then the first sequence number generation configuration data for any one of these items can be edited to update the target sequence number generation table.
[0150] Specifically, the content of the target sequence number generation table can be updated by triggering an edit operation that modifies the target sequence number generation table.
[0151] This approach allows the target sequence number generation table to be more flexible and adaptable, thus better meeting the needs of sequence number generation.
[0152] In one example, when managing the serial number template table or serial number generation table through deletion operations, there are two possible scenarios.
[0153] Scenario 1: When managing the serial number template table through deletion operations, the deletion operation can be performed on the serial number template table and each serial number generation table associated with it.
[0154] Scenario 2: When the sequence number generation table is managed through deletion operations, the deletion operation on the sequence number generation table can be performed in response to the deletion operation on the sequence number generation table.
[0155] In one example, after generating a serial number based on the serial number generation method indicated by the target serial number generation table and storing the generated serial number in the cache, this embodiment of the application further includes the following step S204.
[0156] S204. In response to the client's sequence number retrieval command, determine the sequence number that matches the sequence number retrieval command from the cache; based on the remaining sequence numbers in the cache excluding the matching sequence number, and the number of sequence numbers that the target sequence number generation table can generate, determine the sequence number usage information; return the matching sequence number and the sequence number usage information to the client.
[0157] It's important to note that the sequence number generation instruction is different from the sequence number retrieval instruction. For example, the sequence number retrieval instruction instructs the retrieval of a sequence number directly from the cache, while the sequence number generation instruction instructs the determination of a target sequence number generation table, the generation of a sequence number based on the target table, and the storage of the generated sequence number in the cache. Alternatively, the sequence number retrieval instruction may not only instruct the retrieval of a sequence number directly from the cache, but also, if the cache does not contain a sequence number matching the retrieval instruction, instruct the determination of a target sequence number generation table, the generation of a sequence number based on the target table, and the storage of the generated sequence number in the cache.
[0158] In one example, suppose the cache can store 100 serial numbers. If there are 20 serial numbers remaining in the cache besides the matching serial number, then the serial number usage information can be determined as (100-20) / 100 = 0.8. At this time, the matching serial number and the serial number usage information 0.8 can be returned to the client.
[0159] This method updates the serial number usage information promptly after each serial number is obtained, making the usage status of the serial numbers clear at a glance. This helps staff quickly determine whether the serial number generation configuration data in the current serial number generation table (or serial number template table) needs to be changed, thus ensuring the validity and accuracy of serial number generation and avoiding serial number overflow.
[0160] In one example, after generating a serial number based on the serial number generation method indicated by the target serial number generation table and storing the generated serial number in the cache, this embodiment of the application further includes the following step S205.
[0161] S205. In response to the serial number recycling instruction, determine the serial number to be recycled as indicated by the serial number recycling instruction; if a serial number identical to the serial number to be recycled as indicated by the serial number recycling instruction is determined from the cache, add the identical serial number to the database and delete the identical serial number from the cache.
[0162] The serial number retrieval instruction can specify one or more serial numbers with certain characteristics, such as repetition, continuity, or the presence of specified numbers. In this case, the serial number retrieval instruction could specify serial numbers like "666", "888", "999", or "123". Alternatively, the serial number retrieval instruction can specify all unused serial numbers in the cache. This application does not limit the specific serial numbers specified in the serial number retrieval instruction; the choice is based on actual needs.
[0163] The above method can reclaim unused sequence numbers in the cache, avoiding waste of sequence numbers and improving the utilization rate of sequence numbers.
[0164] In another example, in response to a serial number eviction command, the serial number to be eviction as indicated by the serial number eviction command can be determined; if a serial number identical to the serial number to be eviction as indicated by the serial number eviction command is determined from the cache, the identical serial number is added to the cache persistence table and removed from the cache.
[0165] In this case, upon receiving a new sequence number generation or retrieval instruction, the sequence number in the cache persistence table can be stored in the cache first, thus avoiding the waste of sequence numbers.
[0166] In one example, the sequence number generation method for distributed systems provided in this application can be applied to a service cluster.
[0167] Figure 5 This is a schematic diagram of a service cluster provided in an embodiment of this application. Figure 5 As shown, after detecting a sequence number generation command, it can be distributed to the corresponding service node in the service cluster for processing via TSF. At this time, the service node in the service cluster can access the database to generate a sequence number based on the command and then store the generated sequence number in its cache. Assuming each service node can include two number segments, the sequence numbers stored by each service node can be as follows: Figure 5 As shown, the cached sequence numbers in service node 1 are 1-100 and 101-200, the cached sequence numbers in service node 2 are 201-300 and 301-400, and the cached sequence numbers in service node 3 are 401-500 and 501-600.
[0168] In one example, the serial number generation method for distributed systems provided in this application can also apply database sharding and table partitioning technology. By setting different serial number generation tables and serial number template tables for different serial number generation requirements, and storing the set serial number generation tables and serial number template tables in different databases, multiple databases can respond to serial number generation commands, thereby improving the database processing performance to meet the needs of high concurrency scenarios.
[0169] Figure 6 This is a schematic diagram of the structure of a sequence number generation device for a distributed system provided in an embodiment of this application. Figure 6 As shown, the device 600 includes:
[0170] The receiving unit 601 is used to receive a sequence number generation instruction; wherein the sequence number generation instruction includes business scenario information and request location information; the business scenario information indicates the business scenario in which the sequence number is applied, and the request location information indicates the source location of the sequence number generation instruction;
[0171] The determining unit 602 is used to determine a target sequence number template table based on business scenario information, and to determine a target sequence number generation table that matches the request location information from at least one sequence number generation table associated with the target sequence number template table; wherein, the sequence number template table indicates the sequence number generation method in the corresponding business scenario, and the sequence number generation table indicates the sequence number generation method corresponding to the source location of the sequence number generation instruction.
[0172] The generation unit 603 is used to generate a serial number based on the serial number generation method indicated by the target serial number generation table, and store the generated serial number in the cache.
[0173] Figure 7 This is a schematic diagram of the structure of another serial number generation device for a distributed system provided in an embodiment of this application. For example... Figure 7 As shown, the device 700 includes:
[0174] The receiving unit 701 is used to receive a sequence number generation instruction; wherein the sequence number generation instruction includes business scenario information and request location information; the business scenario information indicates the business scenario in which the sequence number is applied, and the request location information indicates the source location of the sequence number generation instruction;
[0175] The determining unit 702 is used to determine a target sequence number template table based on business scenario information, and to determine a target sequence number generation table that matches the request location information from at least one sequence number generation table associated with the target sequence number template table; wherein, the sequence number template table indicates the sequence number generation method in the corresponding business scenario, and the sequence number generation table indicates the sequence number generation method corresponding to the source location of the sequence number generation instruction.
[0176] In one example, determining unit 702 also includes:
[0177] The creation module 7021 is used to create a new sequence number generation table that matches the requested location information based on the target sequence number template table when no sequence number generation table matching the requested location information is determined from at least one sequence number generation table associated with the target sequence number template table, and to establish an association between the new sequence number generation table and the target sequence number template table.
[0178] In one example, the target sequence number template table includes second sequence number generation configuration data; the second sequence number generation configuration data is used to determine the sequence number generation method in the corresponding business scenario; the first sequence number generation configuration data is the same as the second sequence number generation configuration data.
[0179] The determining unit 702 also includes:
[0180] The editing module 7022 is used to, after detecting an editing operation on the configuration data of any second serial number in the target serial number template table, obtain first configuration data editing information, update the second serial number generation configuration data in the target serial number template table based on the first configuration data editing information, and update the first serial number generation configuration data in each serial number generation table associated with the target serial number template table.
[0181] In one example, the edit module 7022 is also used for:
[0182] After detecting an edit operation on any first sequence number generated configuration data in the sequence number generation table, the second configuration data edit information is obtained, and the first sequence number generated configuration data in the sequence number generation table is updated based on the second configuration data edit information.
[0183] The generation unit 703 is used to generate a serial number based on the serial number generation method indicated by the target serial number generation table, and store the generated serial number in the cache.
[0184] In one example, the target sequence number generation table contains first sequence number generation configuration data; the first sequence number generation configuration data includes at least the sequence number generation range, the sequence number generation mode, and the sequence number generation quantity; the sequence number generation mode indicates the association relationship between adjacent generated sequences.
[0185] The generating unit 703 is also used for:
[0186] Generate a number of serial numbers within the serial number generation range according to the serial number generation pattern, and store the number of serial numbers in the cache.
[0187] In one example, the device is also used for:
[0188] If the target sequence number template table cannot be determined based on the business scenario information, the target sequence number generation table is determined from at least one separate sequence number generation table based on the request location information, and a sequence number is generated based on the sequence number generation method indicated by the target sequence number generation table; wherein, the separate sequence number generation table indicates a sequence number generation table that has not been associated with any sequence number template table.
[0189] In one example, after generating a serial number based on the serial number generation method indicated by the target serial number generation table and storing the generated serial number in a cache, the apparatus further includes:
[0190] The information return module 704 is used to respond to the client's sequence number retrieval command and determine the sequence number that matches the sequence number retrieval command from the cache;
[0191] Based on the remaining sequence numbers in the cache excluding the matching sequence numbers, and the number of sequence numbers that the target sequence number generation table can generate, determine the sequence number usage information;
[0192] The matching serial number and serial number usage information will be returned to the client.
[0193] In one example, the device is also used for:
[0194] In response to a deletion operation on the sequence number template table, a deletion operation is performed on the sequence number template table and each sequence number generation table associated with the sequence number template table.
[0195] In one example, the device also includes:
[0196] The serial number recycling module 705 is used to determine the serial number to be recycled as indicated by the serial number recycling command in response to the serial number recycling command.
[0197] If a serial number is found in the cache that is the same as the serial number to be reclaimed as indicated by the serial number reclamation instruction, the same serial number is added to the database and removed from the cache.
[0198] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 8 As shown, the computer device 800 includes: a memory 801 and a processor 802.
[0199] Memory 801; a memory used to store executable instructions of processor 802.
[0200] The processor 802 is configured to perform the methods provided in the above embodiments.
[0201] The computer device also includes a receiver 803 and a transmitter 804. The receiver 803 is used to receive instructions and data sent by external devices, and the transmitter 804 is used to send instructions and data to external devices.
[0202] Figure 9 This is a block diagram illustrating a computer device according to an exemplary embodiment. The device may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0203] The device 900 may include one or more of the following components: a processing component 902, a memory 904, a power supply component 906, a multimedia component 909, an audio component 910, an input / output (I / O) interface 912, a sensor component 914, and a communication component 916.
[0204] Processing component 902 typically controls the overall operation of device 900, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 902 may include one or more modules to facilitate interaction between processing component 902 and other components. For example, processing component 902 may include a multimedia module to facilitate interaction between multimedia component 909 and processing component 902.
[0205] Memory 904 is configured to store various types of data to support the operation of device 900. Examples of this data include instructions for any application or method operating on device 900, contact data, phonebook data, messages, pictures, videos, etc. Memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0206] Power supply component 906 provides power to various components of device 900. Power supply component 906 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to device 900.
[0207] Multimedia component 909 includes a screen that provides an output interface between device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 909 includes a front-facing camera and / or a rear-facing camera. When device 900 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0208] Audio component 910 is configured to output and / or input audio signals. For example, audio component 910 includes a microphone (MIC) configured to receive external audio signals when device 900 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 904 or transmitted via communication component 916. In some embodiments, audio component 910 also includes a speaker for outputting audio signals.
[0209] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0210] Sensor assembly 914 includes one or more sensors for providing state assessments of various aspects of device 900. For example, sensor assembly 914 may detect the on / off state of device 900, the relative positioning of components such as the display and keypad of device 900, changes in the position of device 900 or a component of device 900, the presence or absence of user contact with device 900, the orientation or acceleration / deceleration of device 900, and temperature changes of device 900. Sensor assembly 914 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 914 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 914 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0211] Communication component 916 is configured to facilitate wired or wireless communication between device 900 and other devices. Device 900 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 916 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 916 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0212] In an exemplary embodiment, the apparatus 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0213] This application also provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, these instructions perform the steps of the distributed system sequence number generation method described in the above method embodiments. The storage medium can be either volatile or non-volatile computer-readable storage.
[0214] This application also provides a computer program product that carries computer execution instructions. The computer execution instructions include instructions that can be used to execute the steps of the distributed system sequence number generation method in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0215] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0216] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for generating a sequence number in a distributed system, characterized in that The method comprises: receiving a serial number generation instruction; wherein the serial number generation instruction comprises service scenario information and request location information; the service scenario information indicates a service scenario to which the serial number applies, and the request location information indicates a source location of the serial number generation instruction; determining a target serial number template table based on the service scenario information, and determining a target serial number generation table that matches the request location information from at least one serial number generation table associated with the target serial number template table; wherein a serial number template table indicates a serial number generation manner in a corresponding service scenario, and a serial number generation table indicates a serial number generation manner corresponding to the source location of the serial number generation instruction; generating a serial number based on the serial number generation manner indicated by the target serial number generation table, and storing the generated serial number in a cache; wherein the target serial number template table comprises second serial number generation configuration data; the target serial number generation table comprises first serial number generation configuration data; the first serial number generation configuration data is the same as the second serial number generation configuration data; The method further comprises: after detecting an editing operation on any second serial number generation configuration data in the target serial number template table, obtaining first configuration data editing information, and updating the second serial number generation configuration data in the target serial number template table based on the first configuration data editing information, and updating the first serial number generation configuration data in each serial number generation table associated with the target serial number template table.
2. The method of claim 1, wherein, The method further comprises: in the case where a serial number generation table that matches the request location information is not determined from at least one serial number generation table associated with the target serial number template table, creating a new serial number generation table that matches the request location information based on the target serial number template table, and establishing an association relationship between the new serial number generation table and the target serial number template table.
3. The method according to claim 1 or 2, characterized in that, The target serial number generation table comprises first serial number generation configuration data; the first serial number generation configuration data comprises at least a serial number generation range, a serial number generation mode, and a serial number generation quantity; the serial number generation mode indicates an association relationship between adjacent generated serial numbers; The method further comprises: generating a serial number based on the serial number generation manner indicated by the target serial number generation table, and storing the generated serial number in a cache; comprising:
4. The method of claim 3, wherein, generating a serial number generation quantity of serial numbers in the serial number generation range according to the serial number generation mode, and storing the serial number generation quantity of serial numbers in the cache. The method further comprises:
5. The method of claim 1, wherein, after detecting an editing operation on any first serial number generation configuration data in a serial number generation table, obtaining second configuration data editing information, and updating the first serial number generation configuration data in the serial number generation table based on the second configuration data editing information. After generating a serial number based on the serial number generation manner indicated by the target serial number generation table, and storing the generated serial number in a cache, the method further comprises: in response to a serial number acquisition instruction of a client, determining a serial number that matches the serial number acquisition instruction from the cache; determining serial number usage information based on the remaining serial numbers in the cache except for the matching serial number, and the quantity of serial numbers that can be generated by the target serial number generation table; return the matched serial number and the serial number usage information to the client.
6. The method of claim 1, wherein, The method further comprises: In a case where a target serial number template table is not determined based on the service scenario information, determining a target serial number generation table from at least one separate serial number generation table based on the request location information, and generating a serial number based on a serial number generation manner indicated by the target serial number generation table; wherein the separate serial number generation table indicates a serial number generation table that is not associated with any serial number template table.
7. The method according to claim 1 or 2, characterized in that, The method further comprises: In response to a deletion operation on a serial number template table, performing a deletion operation on the serial number template table and on each serial number generation table associated with the serial number template table.
8. The method of claim 1, wherein, The method further comprises: In response to a serial number recovery instruction, determining a serial number indicated by the serial number recovery instruction to be recovered; In a case where a serial number identical to the serial number indicated by the serial number recovery instruction to be recovered is determined from the cache, adding the identical serial number to a database and deleting the identical serial number from the cache.
9. An apparatus for generating a sequence number in a distributed system, characterized by Comprise: a receiving unit configured to receive a serial number generation instruction; wherein the serial number generation instruction comprises service scenario information and request location information; the service scenario information indicates a service scenario in which a serial number is applied, and the request location information indicates a source location of the serial number generation instruction; a determining unit configured to determine a target serial number template table based on the service scenario information, and determine a target serial number generation table matched with the request location information from at least one serial number generation table associated with the target serial number template table; wherein a serial number template table indicates a serial number generation manner in a corresponding service scenario, and a serial number generation table indicates a serial number generation manner corresponding to a source location of a serial number generation instruction; a generating unit configured to generate a serial number based on a serial number generation manner indicated by the target serial number generation table, and store the generated serial number in a cache; wherein the target serial number template table comprises second serial number generation configuration data; the target serial number generation table comprises first serial number generation configuration data; the first serial number generation configuration data is identical to the second serial number generation configuration data; The determining unit further comprises: an editing module configured to, after detecting an editing operation on any second serial number generation configuration data in the target serial number template table, acquire first configuration data editing information, and update the second serial number generation configuration data in the target serial number template table based on the first configuration data editing information, and update first serial number generation configuration data in each serial number generation table associated with the target serial number template table.
10. A computer device, comprising: Comprise: a processor, and a memory in communication connection with the processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method according to any one of claims 1 to 8.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Serial number generation method, device and equipment and storage medium
CN110807035A
System and method for providing automatic generation of a local service request
US20110150197A1