Sequence processing method and device, electronic equipment and storage medium
By dynamically adjusting the local cache window value and configuration parameters, the performance degradation caused by static configuration of sequence values and configuration parameters in existing technologies is solved, achieving more efficient sequence access and an improved user experience.
Patent Information
- Application Number
- CN202310908909.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2043-07-24
AI Technical Summary
In existing technologies, the sequence values and configuration parameters provided by the database are statically configured and cannot be dynamically adjusted, which leads to a decrease in the performance of application systems accessing sequences and affects the user experience.
By receiving local sequence retrieval requests, the local cache window value and configuration parameters are dynamically adjusted according to preset rules, including determining the window adjustment factor and configuration parameters, and new local sequences are dynamically obtained.
It improves the efficiency of accessing local sequences, enhances the performance of application systems accessing sequences, and improves the user experience.
Smart Images

Figure CN117235143B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a sequence processing method and device, electronic equipment and a storage medium. BACKGROUND
[0002] Self-increment sequence is used to generate primary key and other application scenarios requiring uniqueness, which is a basic function used frequently by application systems. At present, most databases (such as Oracle database) in the industry adopt the method of segmenting the sequence interval, divide the sequence according to fixed sequence values, and store the divided sequence values in the database product, provide sequence objects for the application system, and the configuration parameters of the provided sequence are also set in advance. In the prior art, when the application system applies for a sequence to the database, the size of each sequence value provided by the database and the configuration parameters of the sequence (such as sequence concatenation prefix, sequence primary key number length, etc.) are statically configured. The local cache window value of the local sequence and the configuration parameters applied to the database each time can only be provided for the application system according to the sequence value and the configuration parameters set in advance by the database, and cannot be dynamically adjusted, which affects the performance of the application system accessing the sequence. SUMMARY
[0003] The present application provides a sequence processing method and device, electronic equipment and a storage medium, which can dynamically adjust the size of the local cache window value of the local sequence and the corresponding configuration parameters of the local sequence when the frequency of the application system accessing the local sequence is relatively high, improve the access efficiency of the local sequence, effectively improve the performance of the application system accessing the sequence, and increase the user experience. In this way, the foregoing technical problems are solved.
[0004] To solve the above technical problems, in a first aspect, an embodiment of the present application provides a sequence processing method applied to an electronic device, the method comprising: receiving a local sequence acquisition request, and applying for a current local sequence to a database according to the local sequence acquisition request; in a case where a sequence value used by the current local sequence reaches a first threshold, determining a new local cache window value of a local sequence applied next time according to a first preset rule; and determining a new configuration parameter of the local sequence applied next time according to a second preset rule; and acquiring a new local sequence from the database according to the new local cache window value and the new configuration parameter.
[0005] The processing method of the sequence can determine a new local cache window value of the next applied local sequence according to a first preset rule when a sequence value used by the current local sequence reaches a first threshold, determine a new configuration parameter of the next applied local sequence according to a second preset rule, and obtain a new local sequence according to the new local cache window value and the new configuration parameter. Therefore, the local cache window value and the configuration parameter of the new local sequence applied from the database can be dynamically adjusted according to the actual use of the local sequence, the access efficiency of the local sequence is improved, the performance of the application system in accessing the sequence is effectively improved, and the user experience is increased.
[0006] In a possible implementation of the first aspect, the determination of the new local cache window value of the next applied local sequence according to the first preset rule includes: determining whether a window adjustment factor is less than a preset adjustment factor, the window adjustment factor being data related to the consumption time of the local sequence; if yes, increasing the initial local cache window value, and determining the new local cache window value according to the increased initial local cache window value; and if no, taking the initial local cache window value as the new local cache window value.
[0007] In the process of determining the new local cache window value of the next applied local sequence, whether to change the size of the local cache window value is determined according to the size of the window adjustment factor related to the consumption time of the local sequence. Therefore, the size of the local cache window value can be dynamically adjusted in real time according to the consumption time of the local sequence, the use demand of the application system for the local sequence is met, the performance of the application system in accessing the sequence is increased, and the user experience is increased.
[0008] In a possible implementation of the first aspect, the determination of the window adjustment factor includes: obtaining a first consumption time at which the sequence value used by the current local sequence reaches the first threshold, and obtaining a second consumption time of the application of the current local sequence to the database; and determining the window adjustment factor according to the first consumption time and the second consumption time.
[0009] The time of the application of the current local sequence to the database is generally much longer than the time of the request of the sequence to the local cache. The window adjustment factor determined according to the first consumption time at which the sequence value used by the current local sequence reaches the first threshold and the second consumption time of the application of the current local sequence to the database can more accurately reflect the use frequency of the local sequence by the application system, and the determination of the window adjustment factor is more reasonable. Then, whether to change the size of the local cache window value is determined according to the window adjustment factor, which can more conform to the actual demand to adjust the size of the local cache window value, increase the performance of the application system in accessing the sequence, and increase the user experience.
[0010] In a possible implementation of the first aspect, the window adjustment factor is determined according to the following formula:
[0011] β = T1 / T2
[0012] wherein β is the window adjustment factor, T1 is the first consumption time, and T2 is the second consumption time.
[0013] The window adjustment factor is determined according to the ratio of the first consumption time at which the sequence value used by the current local sequence reaches the first threshold value to the second consumption time at which the current local sequence is applied for from the database, which is more reasonable and can more accurately reflect the frequency of use of the local sequence by the application system.
[0014] In a possible implementation of the first aspect, the initial local cache window value is increased, and the new local cache window value is determined according to the increased initial local cache window value, including: multiplying the initial local cache window value by a preset adjustment coefficient to obtain the new local cache window value, and the preset adjustment coefficient is greater than 1.
[0015] The determined new local cache window value is obtained by multiplying the initial local cache window value by a preset adjustment coefficient greater than 1. Therefore, in the process of adjusting the local cache window value, the new local cache window value determined based on the size of the initial local cache window value in the process of increasing the local cache window value is more reasonable.
[0016] In a possible implementation of the first aspect, the preset adjustment coefficient is 2.
[0017] In a possible implementation of the first aspect, the first threshold value is 99% of the initial local cache window value of the local sequence.
[0018] Applying for a new local sequence from the database requires a certain buffer time. In the case that the sequence value used by the current local sequence reaches 99% of the initial local cache window value of the local sequence, the new local sequence is obtained from the database, which can ensure the normal use of the current local sequence and also provides a buffer time for applying for a new local sequence from the database. Therefore, after the current local sequence is used up, the new local sequence has also been applied for and can be used immediately, and the user experience is improved.
[0019] In a possible implementation of the first aspect, the new configuration parameter of the local sequence applied next is determined according to a second preset rule, including: determining whether the primary key number used by the current local sequence reaches a second threshold value; if yes, updating the configuration parameter of the sequence, and taking the updated configuration parameter as the new configuration parameter of the local sequence applied next; and if no, taking the original configuration parameter of the sequence as the new configuration parameter of the local sequence applied next.
[0020] In the process of determining the new configuration parameter of the local sequence applied next time, it is judged whether the primary key number used by the current local sequence reaches a second threshold value, and after reaching the second threshold value, the configuration parameter of the sequence is updated. Thus, the configuration parameter of the sequence can be adjusted in real time and dynamically according to the use of the primary key number of the local sequence, the use demand of the application system for the local sequence is met, the performance of the application system accessing the sequence is increased, and the user experience is improved.
[0021] In a possible implementation of the first aspect, the second preset rule is used to determine the new configuration parameter of the local sequence applied next time, including: judging whether the primary key number used by the current local sequence reaches a second threshold value; if yes, judging whether the remaining processing time of the business processed using the current local sequence is less than a first time threshold value; if yes, using the configuration parameter of the original sequence as the new configuration parameter of the local sequence applied next time; if no, updating the configuration parameter of the sequence, and using the updated configuration parameter as the new configuration parameter of the local sequence applied next time.
[0022] In the process of determining the new configuration parameter of the local sequence applied next time, it is judged whether the primary key number used by the current local sequence reaches a second threshold value, and after reaching the second threshold value, it is further judged whether the remaining processing time of the business processed using the current local sequence is less than a first time threshold value, and if no, the configuration parameter of the sequence is updated. Thus, the configuration parameter of the sequence can be adjusted in real time and dynamically according to the use of the primary key number of the local sequence and the remaining processing time of the business, the use demand of the application system for the local sequence is met, the performance of the application system accessing the sequence is increased, and the user experience is improved.
[0023] In a possible implementation of the first aspect, the second threshold value is 90% of the maximum value of the primary key number available for the current local sequence.
[0024] It takes a certain buffer time to apply for a new local sequence to the database, and in the case that the primary key number used by the current local sequence reaches 90% of the maximum value of the primary key number available for the current local sequence, the configuration parameter of the sequence is updated, which can ensure the normal use of the primary key number of the current local sequence and also provides a buffer time for applying for a new local sequence to the database, thereby improving the user experience.
[0025] In a possible implementation of the first aspect, the first time threshold value is 30 minutes, and the second threshold value is 90% of the maximum value of the primary key number available for the current local sequence.
[0026] It takes a certain buffer time to apply a new local sequence to the database. When the primary key number used by the current local sequence reaches 90% of the maximum value of the primary key number that can be used by the current local sequence, and the remaining processing time of the business processed by the current local sequence is greater than 30 minutes, the configuration parameters of the sequence are updated, which can ensure the normal use of the primary key number of the current local sequence, and also gives the buffer time for applying a new local sequence to the database according to the specific business processing time, thereby increasing user experience.
[0027] In a possible implementation of the first aspect, the configuration parameters include a prefix of the primary key number and a length of the primary key number. The updating of the configuration parameters of the sequence includes modifying the prefix of the primary key number and / or modifying the length of the primary key number.
[0028] In a possible implementation of the first aspect, the modifying of the length of the primary key number includes adding 1 to the length of the primary key number.
[0029] The length of the primary key number is modified by adding 1 to the length of the primary key number, so that the new local sequence can be distinguished from the primary key number of the completed local sequence during the process of the primary key number, and the problem of repeated primary key numbers does not occur.
[0030] In a possible implementation of the first aspect, the method further includes that an initial value of the primary key number of the new local sequence is the maximum value of the primary key number that can be used by the current local sequence plus 1.
[0031] The initial value of the primary key number of the new local sequence is the maximum value of the primary key number that can be used by the current local sequence plus 1, which can make the primary key number of the new local sequence different from the primary key number of the current local sequence, and also ensure the continuity of the primary key number of the completed current local sequence and the primary key number of the new local sequence in the same business processing process.
[0032] In a possible implementation of the first aspect, the configuration parameters are updated by a non-relational database.
[0033] The non-relational database does not need to define a data mode in advance, and has a predefined table structure and good scalability. The configuration parameters are updated by the non-relational database, thereby improving the performance of the application system.
[0034] In a second aspect, embodiments of the present application provide a processing apparatus of a sequence, the processing apparatus comprising: a first processing module configured to receive a local sequence acquisition request, and apply for a current local sequence from a database according to the local sequence acquisition request; a second processing module configured to, in a case where a sequence value used by the current local sequence reaches a first threshold of an initial local cache window value of the local sequence, determine a new local cache window value of a next applied local sequence according to a first preset rule; a third processing module configured to determine a new configuration parameter of the next applied local sequence according to a second preset rule; and a fourth processing module configured to acquire a new local sequence from the database according to the new local cache window value and the new configuration parameter.
[0035] In a third aspect, embodiments of the present application provide an electronic device, comprising: a memory configured to store a computer program, the computer program comprising program instructions; and a processor configured to execute the program instructions to cause the electronic device to perform the sequence processing method of the first aspect and / or any possible implementation manner of the first aspect.
[0036] In a fourth aspect, embodiments of the present application provide a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program comprising program instructions, the program instructions being executed by an electronic device to cause the electronic device to perform the sequence processing method of the first aspect and / or any possible implementation manner of the first aspect.
[0037] In a fifth aspect, embodiments of the present application provide a computer program product, comprising computer program / instructions, the computer program / instructions being executed by a processor to implement the sequence processing method of the first aspect and / or any possible implementation manner of the first aspect.
[0038] It can be understood that the beneficial effects of the second aspect to the fifth aspect described above can also be referred to the related description in the first aspect, which will not be repeated here.
[0039] Beneficial effects of the present application:
[0040] Based on the sequence processing method provided by the present application, when the sequence value used by the current local sequence reaches the first threshold, the new local cache window value of the next applied local sequence is determined according to the first preset rule, the new configuration parameter of the next applied local sequence is determined according to the second preset rule, and the new local sequence is acquired according to the new local cache window value and the new configuration parameter. Therefore, the local cache window value and the configuration parameter of the new local sequence applied from the database can be dynamically adjusted according to the actual use of the local sequence, the access efficiency of the local sequence is improved, the performance of the application system accessing the sequence is effectively improved, and the user experience is increased. BRIEF DESCRIPTION OF DRAWINGS
[0041] The accompanying drawings, which are incorporated herein and constitute part of this specification, illustrate implementations consistent with the present application and, together with the description, further serve to explain the principles of the application.
[0042] Figure 1 is a schematic diagram showing a storage structure of sequence resources in a database in the prior art;
[0043] Figure 2 is a schematic diagram showing a system including an electronic device and a database according to some implementations of the present application;
[0044] Figure 3 is a flowchart showing a processing method of a sequence according to some implementations of the present application;
[0045] Figure 4 is a schematic diagram showing a storage structure of sequence resources in a database according to some implementations of the present application;
[0046] Figure 5 is a schematic diagram showing a sequence data structure storage according to some implementations of the present application;
[0047] Figure 6 is a flowchart showing a determination of a new local cache window value of a local sequence for a next application according to a first preset rule according to some implementations of the present application;
[0048] Figure 7 is a flowchart showing a determination of a window adjustment factor according to some implementations of the present application;
[0049] Figure 8 is a flowchart showing a determination of a new configuration parameter of a local sequence for a next application according to a second preset rule according to some implementations of the present application;
[0050] Figure 9 is another flowchart showing a determination of a new configuration parameter of a local sequence for a next application according to a second preset rule according to some implementations of the present application;
[0051] Figure 10 is a flowchart showing another processing method of a sequence according to some implementations of the present application;
[0052] Figure 11 is a flowchart showing another processing method of a sequence according to some implementations of the present application;
[0053] Figure 12 is a structural block diagram of a processing apparatus of a sequence according to some implementations of the present application;
[0054] Figure 13 is a structural block diagram of an electronic device according to some implementations of the present application.
[0055] The specific embodiments of the present application have been shown and described in the above description, and will be described in more detail in the following. The drawings and the written description are not intended to limit the scope of the present application in any way, but to explain the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0056] The technical solutions of the present application will be described in further detail below in conjunction with the drawings.
[0057] It should be noted that the acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with the relevant provisions of national laws and regulations.
[0058] As described above, in the prior art, the self-increment sequence is used in application scenarios requiring uniqueness such as generating primary keys, which is a basic function used frequently by application systems. At present, most databases in the industry (such as Oracle database) divide the sequence into intervals using segmented cache sequence intervals, divide the sequence according to fixed sequence values, and store the divided sequence values in the database product to provide sequence objects for the application system. The configuration parameters of the provided sequence are also set in advance. In the prior art, when the application system applies for a sequence from the database, the size of each sequence value provided by the database and the configuration parameters of the sequence (such as sequence concatenation prefix, sequence primary key number length, etc.) are statically configured. The local cache window value and the configuration parameters of the local sequence applied for each time from the database can only be provided for the application system according to the sequence values and the configuration parameters set in advance by the database, and cannot be dynamically adjusted, which affects the performance of the application system accessing the sequence.
[0059] Next, the storage and acquisition process of the sequence in the prior art will be briefly introduced.
[0060] In the prior art, the resources of the sequence are uniformly stored in the database (such as a domestic database), and the current unused sequence resources are stored in the database library table. The sequence is stored according to a certain sequence value. For example, Figure 1As shown, it is an existing sequence physical storage architecture. In the domestic database, there are a plurality of unused sequence clusters (AP1, AP2, …, APn) which can also be called sequence resources stored in sequence. Each sequence cluster is set with a fragment of stored sequences (such as Cache1, Cache2, …, Cachen) according to the provisions. Each fragment Cache1, Cache2, …, Cachen corresponds to a sequence. In general, the size of each sequence number segment of the stored sequence is the same, such as 1000. When the application system on the electronic device needs to use the sequence for business processing, it first applies for a local sequence to the domestic database. If the application is successful and the database judges that the first sequence resource AP1 is not used, the database will return the first sequence resource AP1 to the local application system for use. The maximum segment value of the sequence value that can be used by the first local sequence (as an example of the current local sequence) returned to the local electronic device is the value corresponding to Cache1 set by the Cache1, such as 1000. If it is found that the number of used sequences of the first local sequence reaches a certain critical value (as an example of the first threshold), such as 99% of the maximum segment value of the sequence value that can be used, the electronic device applies for a new sequence resource to the database. At this time, the database will return the second unused sequence resource AP2 to the local application system of the electronic device in sequence. The maximum segment value of the sequence value that can be used by the returned second local sequence (as an example of the new local sequence) is the sequence value corresponding to Cache2, such as 1000.
[0061] However, with the development of business, the cluster application access sequence pressure is gradually increasing, and the access point cluster (APCluster, AP cluster) often stores sequence resources locally for application systems to use. The development of business is also accompanied by an increase in data volume. During the busy period of business, the use frequency of local sequences is also greatly increased. However, the maximum segment value of the sequence value of the local sequence applied by the electronic device (which can also be called a local application system) to the database is set in advance. If the set value is small, the sequence applied each time will be quickly used up. Therefore, the electronic device needs to frequently apply for sequences to the database, and the time used by the electronic device to apply for sequences to the database is much longer than the time used by the application system to apply for sequences to the local cache, which seriously affects the performance of the application system accessing the sequence.
[0062] To solve the above problems, the existing database products generally set a fixed size of the sequence number segment value according to the use scenario of the sequence to improve the efficiency. For the scenario where the local sequence is used frequently, the cache (i.e., the maximum segment value) of the sequence applied each time needs to be set a little larger, and for the scenario where the local sequence is used slowly, the cache needs to be set a little smaller. However, in this method, the frequency of the use of the local sequence for each scenario is mostly determined by the user's experience, which leads to the size of the sequence number segment value being set by experience, but the experience may have deviations and uncertainties. Further, the sequence configuration parameters can only be statically configured when the sequence is divided, such as the sequence concatenation prefix (as an example of the prefix of the primary key number), the sequence length (as an example of the length of the primary key number), and the like, and cannot be dynamically adjusted, which is not flexible. In addition, the use frequency of the local sequence changes dynamically, such as the peak period of access of the application system, the local sequence is consumed fast, and the trough period of access of the application system, the sequence is consumed slowly. The fixed cache size (i.e., the sequence number segment value) cannot be adaptively adjusted, which leads to the use performance of the local sequence not being optimal. In addition, the traditional database cannot be dynamically horizontally expanded, which leads to the sequence generation server also being unable to be dynamically horizontally expanded.
[0063] Based on this, the present application provides a sequence processing method and device, electronic equipment and storage medium, which can dynamically adjust the size of the local cache window value of the local sequence and the corresponding configuration parameters of the local sequence when the application system accesses the local sequence frequently, improve the access efficiency of the local sequence, effectively improve the performance of the application system accessing the sequence, and increase the user experience.
[0064] Next, the implementation process and advantages of the sequence processing method provided by the present application will be described in detail with reference to the accompanying Figures 2-11 drawings.
[0065] As Figure 2 shown in the accompanying drawings, the sequence processing method provided by the present application is applied to a system including an electronic equipment 100 and a database 200. The user uses the electronic equipment 100 to perform the processing of the unique primary key business, such as establishing a contract number, generating a user identity primary key, and the like. At this time, the application system on the electronic equipment 100 first applies for a local sequence to the database 200. After receiving the request for applying for the local sequence sent by the electronic equipment 100, the database 200 allocates the unused sequence resource to the electronic equipment 100, and the electronic equipment 100 uses the local sequence provided by the database 200 to perform the processing of the primary key business.
[0066] In an implementation manner of the present application, as Figure 3 shown in the accompanying drawings, the sequence processing method provided by the present application includes the following steps:
[0067] S100: receiving a local sequence acquisition request, and applying for a current local sequence from a database according to the local sequence acquisition request.
[0068] S200: in a case where a sequence value used by the current local sequence reaches a first threshold, determining a new local cache window value of the local sequence applied next according to a first preset rule.
[0069] S300: determining a new configuration parameter of the local sequence applied next according to a second preset rule.
[0070] S400: acquiring a new local sequence from the database according to the new local cache window value and the new configuration parameter.
[0071] Based on the sequence processing method provided in the application, the electronic device 100 can determine a new local cache window value of the local sequence applied next according to a first preset rule when a sequence value used by the current local sequence reaches a first threshold, and determine a new configuration parameter of the local sequence applied next according to a second preset rule, and acquire a new local sequence from the database 200 according to the new local cache window value and the new configuration parameter. Therefore, the electronic device 100 can dynamically adjust the local cache window value and the configuration parameter of the new local sequence applied from the database 200 according to the actual use of the local sequence, improve the access efficiency of the local sequence, effectively improve the performance of the application system accessing the sequence, and increase the user experience.
[0072] The sequence value used by the local sequence refers to the number of number segments already used in the local sequence with a series of number segments applied from the database 200 under the current business processing state. For example, the current local sequence applied from the database 200 can use 1000 number segments, and 600 primary key numbers (such as 600 contract numbers) have been generated, which indicates that 600 sequence number segments have been used, i.e., the sequence value used by the local sequence is 600. When 1000 primary key numbers are generated, it indicates that the number segments of the current local sequence have been used up, i.e., the current local sequence has been used up, and the electronic device 100 needs to re-apply for a sequence from the database 200 for subsequent business use.
[0073] The local cache window value refers to the maximum number segment value that the local sequence applied by the electronic device 100 from the database 200 can store. For example, the local cache window value is 1000, which indicates that when the electronic device 100 applies for a local sequence from the database 200, the number segment value of the local sequence can be up to 1000, i.e., at most 1000 primary keys or numbers can be generated.
[0074] Furthermore, steps S200 and S300 can be executed either S200 first and then S300, or S300 first and then S200, or they can be executed simultaneously.
[0075] Next, in step S100, a local sequence acquisition request is received, and the content of the current local sequence is requested from the database based on the local sequence acquisition request for description.
[0076] First, the storage content of the sequence in database 200 in this application will be described.
[0077] like Figure 4 As shown, in one implementation of this application, the unused sequence resources stored in the database 200 are stored in the form of sequence fragments. The specific sequence resources are AP1, AP2...APn. Each sequence resource is configured with a segment of sequence values that can be stored, such as Cache1, Cache2...Cachen. Each sequence fragment corresponds to a certain number segment value.
[0078] Furthermore, such as Figure 5 As shown, in one implementation of this application, each sequence resource (e.g., AP1) is stored using a data structure of two BlockNumber blocks. Each BlockNumber block stores the sequence number segment resources that it can provide for the sequence. The two sequence BlockNumber blocks are stored using a linked list. BlockNumber1 stores the sequence number segment [1, k], and BlockNumber2 stores the sequence number segment [k+1, 2k]. That is, the maximum number segment value of the local sequence that the sequence resource AP1 can provide is 2k.
[0079] Each sequence resource also stores a configuration parameter fragment (i.e., a configuration parameter cache). Configuration parameters can include a sequence concatenation prefix and / or sequence length. The sequence concatenation prefix is the first character of the unique primary key generated during business processing using the sequence; it can be a letter, such as A, B, C, etc., or a fixed number. The sequence length refers to the length of the generated unique primary key number, such as 3 digits (001, 002, etc.).
[0080] When the user processes the business with the primary key number uniqueness requirement, the user needs to first apply for the unused sequence resource to the database 200 through the electronic device 100. After the database 200 receives the local sequence acquisition request, the first unused sequence resource AP1 is provided to the electronic device 100 as the current local sequence. The maximum number of values of the primary key number generated by the current local sequence is the number segment value corresponding to Cache1. Then, the user generates the primary key according to the content in the configuration parameter and uses the local sequence to process the business (such as generating the contract number business).
[0081] In an implementation manner of the present application, the configuration parameter of each sequence is configured or updated through the non-relational database. For example, as shown in FIG. 2, the Redis database can be used. The non-relational database does not need to define the data mode in advance, and the table structure is predefined. The non-relational database has good scalability, and the configuration parameter is updated through the non-relational database, thereby improving the performance of the application system. Figure 4
[0082] Next, the content of the new local cache window value of the next local sequence applied according to the first preset rule is described in the case that the sequence value used by the current local sequence reaches the first threshold.
[0083] In order to ensure the continuity of use, that is, the business processing can be performed without interruption after the use of the previous local sequence, the application of the next local sequence is not performed after the number segment of the previous local sequence is completely used. The application of the next local sequence is started when the use of the current local sequence reaches the first threshold, so that the new local sequence is applied to the local after the number segment of the current local sequence is used up, and the new local sequence can be immediately used.
[0084] Therefore, in an implementation manner of the present application, the first threshold is 99% of the initial local cache window value of the local sequence.
[0085] The initial local cache window value refers to the maximum number segment value of the sequence that can be stored locally when the sequence is applied for the first time in the process of business processing. For example, if the initial local cache window value is 1000, the number segment value of the local sequence applied for the first time (i.e., the current local sequence) is also 1000. When the sequence value used by the current local sequence reaches the first threshold, i.e., when the number segment value used by the current local sequence reaches 990, it means that only 10 number segments can be used, i.e., only 10 primary keys or numbers can be generated, at this time, a new local sequence needs to be applied. Therefore, the normal use of the current local sequence is ensured, and the buffer time for the electronic device 100 to apply for a new local sequence from the database 200 is also given, so that the new local sequence can be applied for immediately after the current local sequence is used up, and the user experience is improved.
[0086] In an implementation manner of the present application, as shown in Figure 6 the new local cache window value of the local sequence applied for next time is determined according to the first preset rule, including the following steps:
[0087] It is determined whether the window adjustment factor is less than the preset adjustment factor, the window adjustment factor being data related to the consumption time of the local sequence; if yes, the initial local cache window value is increased, and the new local cache window value is determined according to the increased initial local cache window value; if no, the initial local cache window value is taken as the new local cache window value.
[0088] In the process of determining the new local cache window value of the local sequence applied for next time, it is determined whether the size of the window adjustment factor related to the consumption time of the local sequence is changed. Therefore, according to the consumption time of the local sequence, the size of the local cache window value can be adjusted in real time and dynamically, the use demand of the application system for the local sequence is met, the performance of the application system accessing the sequence is improved, and the user experience is improved.
[0089] In an implementation manner of the present application, the preset adjustment factor is 10, which is mainly obtained according to experience and the derivation relationship of the consumption time.
[0090] In an implementation manner of the present application, as shown in Figure 7 the window adjustment factor is determined, including the following steps:
[0091] S201: Obtain the first consumption time when the sequence value used by the current local sequence reaches the first threshold, and the second consumption time of applying for the current local sequence from the database.
[0092] S202: Determine a window adjustment factor according to the first consumption time and the second consumption time.
[0093] The time of applying for the current local sequence from the database 200 is much greater than the time of requesting the sequence from the local cache of the electronic device 100, and generally takes more than 10 times (related to specific database products, network time consumption, and the mechanism of implementing the local sequence, etc.). The window adjustment factor determined according to the first consumption time of reaching the first threshold by the sequence value used by the current local sequence and the second consumption time of applying for the current local sequence from the database 200 can more accurately reflect the current use frequency of the local sequence by the application system, and the determination of the window adjustment factor is also more reasonable. Further, judging whether to change the size of the local cache window value according to the window adjustment factor can more conform to the actual demand to adjust the size of the local cache window value, increase the performance of the application system to access the sequence, and increase the user experience.
[0094] In an implementation manner of the present application, the window adjustment factor is determined according to the following formula:
[0095] β = T1 / T2
[0096] Wherein, β is the window adjustment factor, T1 is the first consumption time, and T2 is the second consumption time.
[0097] The window adjustment factor determined according to the ratio of the first consumption time of reaching the first threshold by the sequence value used by the current local sequence and the second consumption time of applying for the current local sequence from the database is more reasonable, and can more accurately reflect the current use frequency of the local sequence by the application system.
[0098] In an implementation manner of the present application, the initial local cache window value is increased, and the new local cache window value is determined according to the increased initial local cache window value, including: multiplying the initial local cache window value by a preset adjustment coefficient to obtain the new local cache window value, and the preset adjustment coefficient is greater than 1.
[0099] The determined new local cache window value is obtained by multiplying the initial local cache window value by the preset adjustment coefficient greater than 1. Therefore, in the process of adjusting the local cache window value, in the process of increasing the local cache window value, the new local cache window value determined based on the size of the initial local cache window value is more reasonable.
[0100] In an implementation manner of the present application, the preset adjustment coefficient is 2.
[0101] When the window adjustment factor is less than the preset adjustment factor, it indicates that the first consumption time of the sequence value used by the current local sequence reaching the first threshold is relatively small, that is, the local sequence is used relatively fast. It indicates that the frequency of using the local sequence in the current scenario is relatively high. Therefore, the initial local cache window value is increased, that is, the number segment value of the local sequence applied next time is increased, so that the new local sequence can use more number segment values, that is, the local sequence applied once can generate more primary keys or numbers.
[0102] In combination Figure 5 As shown in the storage structure of the sequence provided in the present application, in the process of applying the local sequence for the first time, the number segment of the local sequence is applied according to the initial local cache window value k (such as 1000). The database provides the sequence number segment of 1-k in BlockNumber1 to the local for use in the process of the user processing the business. When it is judged that the initial local cache window value is to be increased and the preset adjustment coefficient is 2, it indicates that the maximum value of the number segment that can be stored in the local for the local sequence applied next time is 2k. At this time, when the new local sequence is applied, the database 200 will provide the sequence number segment of BlockNumber1 and BlockNumber2 in the sequence resource AP2 to the local according to the adjusted new local cache window value, and the number of primary keys or numbers that can be generated by the local sequence applied this time is 2k (such as 2000). In this way, each time when the current local sequence uses reaches the first threshold, the calculation of the window adjustment factor is performed, and the size of the local cache window value is dynamically adjusted according to the calculation result of the window adjustment factor, which effectively reduces the frequency of applying the sequence to the database 200, improves the access efficiency of the local sequence, effectively improves the performance of the application system accessing the sequence, and increases the user experience.
[0103] In an implementation manner of the present application, the initial local cache window value can also be increased by a fixed value on the initial local cache window value. For example, 500 is added each time.
[0104] Next, the content of the new configuration parameter of the local sequence applied next time is described according to the second preset rule in step S300.
[0105] In an implementation manner of the present application, as Figure 8 shown, the new configuration parameter of the local sequence applied next time is determined according to the second preset rule, including: judging whether the primary key number used by the current local sequence reaches a second threshold; if yes, updating the configuration parameter of the sequence, and taking the updated configuration parameter as the new configuration parameter of the local sequence applied next time; and if no, taking the original configuration parameter of the sequence as the new configuration parameter of the local sequence applied next time.
[0106] In the process of determining the new configuration parameter of the local sequence of the next application, it is judged whether the primary key number used by the current local sequence reaches a second threshold value, and after reaching the second threshold value, the configuration parameter of the sequence is updated. Thus, the configuration parameter of the sequence can be dynamically adjusted in real time according to the use of the primary key number of the local sequence, the use demand of the application system for the local sequence is met, the performance of the application system accessing the sequence is increased, and the user experience is improved.
[0107] In an implementation manner of the present application, the second threshold value is 90% of the maximum value of the primary key number that can be used by the current local sequence.
[0108] The primary key number used by the current local sequence refers to the configuration parameter set in advance in the process of generating the primary key or number by using the local sequence, for example, each number starts with the letter A, the length of the number is at most 5 (i.e., the maximum value is 99999), etc. The maximum value of the primary key number that can be used by the current local sequence is the maximum number that can be input by the primary key number. The sequence is used to generate the primary key in the business with unique requirements, and in the process of generating the primary key, the self-increment or self-decrement mode is generally used, for example, the first primary key number is 1, and the next number is 2. However, due to some regulations of the database, in the process of setting the number format that can be used by the primary key, the maximum length of the number is limited, and thus the maximum value of the primary key number is limited. When the primary key number used by the current local sequence reaches 90% of the maximum value of the primary key number that can be used by the current local sequence, it is indicated that the primary key number that can be used under the configuration parameter of the current sequence is not enough, and if the current sequence is continuously used, the primary key may not be generated. Therefore, in the process of applying for a new local sequence, the configuration parameter corresponding to the new local sequence needs to be modified, and thus the number of the primary key number that can be generated is increased.
[0109] In an implementation manner of the present application, the configuration parameter includes the prefix of the primary key number and the length of the primary key number, and updating the configuration parameter of the sequence includes modifying the prefix of the primary key number and / or modifying the length of the primary key number.
[0110] For example, in the configuration parameter of the current local sequence, it is specified that the format of the generated primary key or number is Axxxx, i.e., the prefix of the primary key number, and the length of the primary key number is 5. At this time, in the process of modification, the prefix of the primary key number can be modified to Bxxxx, the length of the primary key number can be modified to 6 to Bxxxxx, or the prefix of the primary key number and the length of the primary key number can be simultaneously modified to Bxxxxx.
[0111] Therefore, in an implementation manner of the present application, modifying the length of the primary key number includes adding 1 to the length of the primary key number.
[0112] However, the scenario that the configuration parameter of the sequence needs to be modified is not limited to the case that the primary key number used by the current local sequence reaches 90% of the maximum value of the primary key number that can be used by the current local sequence due to too fast business development.
[0113] In addition, in the migration process of the application system, in order to effectively distinguish between old and new data, the primary key number is modified. At this time, the prefix or length of the newly generated primary key of the migrated sequence needs to be modified to distinguish between them. For example, the primary key number rule of the sequence configuration parameter in the old system is Axxxx. After migration, the corresponding data needs to be moved to the new sequence in the new system. The primary key number rule of the configuration parameter of the new sequence can be Bxxxxx, and the data in the old system is migrated to the new system.
[0114] In an implementation manner of the present application, the initial value of the primary key number of the new local sequence is the maximum value of the primary key number that can be used by the current local sequence plus 1.
[0115] That is, if the maximum value of the primary key number that can be used by the current local sequence is 99999, the initial value of the primary key number of the new local sequence is 100000, and in the subsequent process of generating the primary key, it is sequentially increased and will not be repeated with the existing number.
[0116] Modifying the length of the primary key number includes adding 1 to the length of the primary key number, so that the new local sequence can be obviously distinguished from the primary key number of the local sequence that has been completed in the process of generating the primary key number, and the problem of repeated primary key number will not occur.
[0117] In an implementation manner of the present application, as shown in Figure 9 the new configuration parameter of the local sequence applied next time is determined according to a second preset rule, including the following steps:
[0118] It is judged whether the primary key number used by the current local sequence reaches a second threshold value.
[0119] If yes, it is judged whether the remaining processing time of the business processed by using the current local sequence is less than a first time threshold value.
[0120] If yes, the configuration parameter of the original sequence is taken as the new configuration parameter of the local sequence applied next time.
[0121] If no, the configuration parameter of the sequence is updated, and the updated configuration parameter is taken as the new configuration parameter of the local sequence applied next time.
[0122] In some application scenarios, such as bank generating business number, the process of generating primary key by using sequence will correspondingly mark the generated date in front of each number. Therefore, when considering whether the primary key number is sufficient, it is only necessary to consider whether the use of the primary key number in the business processing process of the day is sufficient. For example, the bank closes at five o'clock, and generally stops business at 4:30. Therefore, at this time, no new business number will be generated. That is, in the case that the primary key number used by the current local sequence reaches 90% of the maximum value of the primary key number that can be used by the current local sequence, if it is judged that the remaining processing time of the business (such as bank business) processed by the current local sequence is also less than the first time threshold, it is indicated that even if the primary key number is not enough, the length of the primary key number does not need to be increased.
[0123] It takes a certain buffer time to apply for a new local sequence to the database. In the case that the primary key number used by the current local sequence reaches 90% of the maximum value of the primary key number that can be used by the current local sequence, and the remaining processing time of the business processed by the current local sequence is greater than 30 minutes, the configuration parameters of the sequence are updated, which can ensure the normal use of the primary key number of the current local sequence, and also gives the buffer time for applying for a new local sequence to the database according to the specific business processing time, thereby increasing the user experience.
[0124] Therefore, in an implementation manner of the present application, the first time threshold is 30 minutes, and the second threshold is 90% of the maximum value of the primary key number that can be used by the current local sequence.
[0125] Finally, step S400 is performed to obtain the content of the new local sequence from the database according to the new local cache window value and the new configuration parameters.
[0126] In an implementation manner of the present application, the sequence processing method provided by the present application, as shown in Figure 10 includes the following steps:
[0127] In the process of using the local sequence, the electronic device judges whether the local sequence resource reaches the critical value k in real time. If the critical value is not reached, the next sequence value that can be used by the local sequence is directly returned.
[0128] If the locally used sequence value reaches a critical value, a judgment is made as to whether to adjust the size of the local sequence cache window, if not, a new BlockNumber resource (i.e. sequence resource) is applied for from the database using k, the database provides a new local sequence, and the local sequence cache is updated. If adjustment is needed, the size of the local cache window value of the new local sequence is first adjusted to 2k, i.e. k = 2k, and then a new sequence resource segment is applied for from the database using the latest sequence cache window size (i.e. using 2k to apply for a new BlockNumber resource from the database), and is stored in the local cache.
[0129] Further, as shown in Figure 11 the size adjustment of the local cache window is adjusted by the following algorithm:
[0130] The sequence resource consumption time of BlockNumber1 is calculated as t1 milliseconds (the corresponding local cache window value is k), and the time consumption of applying for a sequence resource from the database is t2 milliseconds. Since the time consumption of accessing the database once is much higher than the time consumption of obtaining the sequence from the local cache, the time consumption is generally more than 10 times. At the same time, the sequence cache window adjustment factor a is initialized and set.
[0131] Then t1 / t2 is calculated, and it is judged whether t1 / t2 is less than a. When it is less than the window adjustment factor a (in order to ensure that the probability of obtaining the sequence from the local cache is more than 99.99%, the adjustment factor a is at least 10 according to experience and derivation formula), the threshold k of BlockNumber is adjusted to 2k. Because the BlockNumber sequence resource consumption of the local cache is too fast, it is necessary to frequently query the database to obtain the sequence resource. At this time, the threshold k of BlockNumber is adjusted to 2k, and the sequence resource obtained from the database each time is twice the previous one, and the capacity of the local storage sequence resource is doubled, which can increase the hit rate of obtaining the sequence from the local cache. If not, the size of the local cache window value is not adjusted, and the current cache window size is maintained.
[0132] After adjusting BlockNumber, the above steps are repeated until t1 / t2 is greater than a.
[0133] The sequence processing method provided in the application can also be called a generation mechanism of a dynamically configured self-incrementing sequence based on a distributed cluster local cache. The generation value of the sequence can be dynamically adjusted by dynamically adjusting the parameter configuration of the sequence, including the splicing prefix of the sequence and the sequence length, and dynamically and timely taking effect on the related configuration, so as to dynamically adjust the generation value of the sequence.
[0134] According to the pressure of real-time access to the sequence by the application system, the size of the local sequence cache window is dynamically adjusted, the access efficiency of the local sequence is improved, and the overall performance of the application system accessing the sequence is improved.
[0135] The method and mechanism of distributed sequence generation provided in the application no longer rely on specific functions and characteristics of a specific database, thereby breaking the dependence on a specific database product and realizing complete autonomous control of the function.
[0136] The sequence function provided in the application is transparent to an application system, and when the application system is replaced and reformed by a domestic database, the application code using the sequence function basically does not need to be reformed, thereby reducing the workload of the reform of the application system domestication.
[0137] The sequence function provided in the application can adjust the window size of the local sequence cache according to the pressure and frequency of the application system accessing the sequence, ensure the high hit rate of the application system accessing the local cache sequence number, reduce the frequency of accessing the database, thereby improving the overall access performance of the application system obtaining the sequence, and can realize dynamic expansion of the sequence function access through expansion of the AP physical machine.
[0138] The application provides a generation mechanism of an auto-increment sequence, which can dynamically adjust the parameter configuration of the sequence, including the splicing prefix of the sequence and the sequence length and the like, and dynamically and timely make the sequence configuration effective, thereby achieving dynamic adjustment of the generated value of the sequence.
[0139] The application modifies the configuration parameters of the sequence in real time, including the splicing prefix of the sequence and the length of the sequence, and since the sequence parameters in the local cache are kept in real time synchronization with the distributed cache, the sequence value returned to the application is affected in real time, thereby achieving the effect of dynamically adjusting the returned value of the sequence, including the length of the sequence and the prefix of the sequence and the like.
[0140] The method and device of the application provide dynamic configuration of the sequence number generation based on a distributed cluster, the resources of the sequence are uniformly stored in a domestic database, the current unused sequence resources are stored in the database library table, the sequence section number in the local cache is uniformly obtained from the database, and the parameter configuration in the local cache is uniformly obtained from the distributed cache Redis and is synchronized. The local sequence device returns the globally unique sequence value to the application in low latency by assembling the local sequence parameter configuration and the sequence section cache value.
[0141] When the application system needs to use the sequence, first, the sequence value is applied from the local sequence device, the local sequence device applies the sequence value to the local sequence device as the parameter (configuration parameter, local cache sequence), if the application is successful, the sequence value is returned to the application system. If it is found that the local cache usage of the sequence reaches a certain critical value, the database is applied for a new sequence resource of the sequence, after the application is successful, the segmented cache resource provided by the database is stored in the local memory, and the next sequence is returned to the application system. With the development of business, the access pressure of the cluster application to the sequence may gradually become large, if the current cluster cannot meet the access pressure of the sequence resource. Since the AP cluster stores the sequence resource in the local cache, the capacity can be expanded by horizontally expanding the AP, so as to reduce the access pressure of the sequence.
[0142] Please refer to Figure 12 , Figure 12 The sequence processing device of the application is shown in the figure, and the device comprises:
[0143] The first processing module is configured to receive a local sequence acquisition request, and apply for a current local sequence from the database according to the local sequence acquisition request.
[0144] The second processing module is configured to, in the case that the sequence value used by the current local sequence reaches the first threshold value of the initial local cache window value of the local sequence, determine the new local cache window value of the local sequence applied next time according to the first preset rule.
[0145] The third processing module is configured to determine the new configuration parameter of the local sequence applied next time according to the second preset rule.
[0146] The fourth processing module is configured to acquire the new local sequence from the database according to the new local cache window value and the new configuration parameter.
[0147] The sequence processing device provided by the application can determine the new local cache window value of the local sequence applied next time according to the first preset rule when the sequence value used by the current local sequence reaches the first threshold value, and determine the new configuration parameter of the local sequence applied next time according to the second preset rule, and acquire the new local sequence according to the new local cache window value and the new configuration parameter. Therefore, the local cache window value and the configuration parameter of the new local sequence applied from the database can be dynamically adjusted according to the actual use of the local sequence, the access efficiency of the local sequence is improved, the performance of the application system accessing the sequence is effectively improved, and the user experience is increased.
[0148] It should be noted that the division of the various modules of the above apparatus is only a logical functional division, and in actual implementation, all or part can be integrated into one physical entity, or can be physically separated. And these modules can all be implemented in the form of software called by a processing element; all can be implemented in the form of hardware; some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the processing module can be a separately established processing element, or can be integrated in a chip of the above apparatus, in addition, it can also be in the form of program code stored in the memory of the above apparatus, and called and executed by a processing element of the above apparatus. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or can be independently implemented. The processing element here can be an integrated circuit with signal processing capability. In the implementation process, each step of the above method or each module can be completed by the integrated logic circuit of the hardware in the processor element or the instruction in the form of software.
[0149] Referring to Figure 13 , Figure 13 Figure 1 shows a structural block diagram of an electronic device provided by an implementation of the present application. The electronic device can include one or more processors 1002, system control logic 1008 connected to at least one of the processors 1002, system memory 1004 connected to the system control logic 1008, non-volatile memory (NVM) 1006 connected to the system control logic 1008, and network interface 1010 connected to the system control logic 1008.
[0150] The processor 1002 can include one or more single-core or multi-core processors. The processor 1002 can include any combination of general-purpose processors and dedicated processors (e.g., graphics processors, application processors, baseband processors, etc.). In the implementations herein, the processor 1002 can be configured to perform the sequence of processing methods described above.
[0151] In some implementations, the system control logic 1008 can include any suitable interface controller to provide any suitable interface to at least one of the processors 1002 and / or any suitable device or component in communication with the system control logic 1008.
[0152] In some implementations, system control logic 1008 can include one or more memory controllers to provide an interface to system memory 1004. System memory 1004 can be used to load and store data and / or instructions. In some implementations, system memory 1004 of an electronic device can include any suitable volatile memory, such as suitable Dynamic Random Access Memory (DRAM).
[0153] NVM / memory 1006 can include one or more tangible, non-transitory computer- readable media for storage of data and / or instructions. In some implementations, NVM / memory 1006 can include any suitable non-volatile memory, such as flash memory, and / or any suitable non-volatile storage device, such as at least one of a Hard Disk Drive (HDD), a Compact Disc (CD) drive, a Digital Versatile Disc (DVD) drive.
[0154] NVM / memory 1006 can include a portion of the storage resources installed on the device of the electronic device, or it can be accessible by the device but not necessarily a part of the device. For example, NVM / memory 1006 can be accessed over a network via network interface 1010.
[0155] In particular, system memory 1004 and NVM / memory 1006 can include, respectively, a temporary copy and a permanent copy of instructions 1020. Instructions 1020 can include instructions that, when executed by at least one of processors 1002, cause the electronic device to implement the aforementioned sequence of processing methods. In some implementations, instructions 1020, hardware, firmware, and / or software components thereof can additionally / alternatively be placed in system control logic 1008, network interface 1010, and / or processors 1002.
[0156] Network interface 1010 can include a transceiver to provide a radio interface for the electronic device to communicate with any other suitable device (e.g., a front-end module, an antenna, etc.) over one or more networks. In some implementations, network interface 1010 can be integrated with other components of the electronic device. For example, network interface 1010 can be integrated with at least one of processors 1002, system memory 1004, NVM / memory 1006, and a firmware device (not shown) having instructions that, when executed by at least one of processors 1002, cause the electronic device to implement the aforementioned sequence of processing methods.
[0157] The network interface 1010 can further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 1010 can be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.
[0158] In one implementation, at least one of the processors 1002 can be packaged together with logic for one or more controllers of the system control logic 1008 to form a system in a package (SiP). In one implementation, at least one of the processors 1002 can be integrated on the same die with logic for one or more controllers of the system control logic 1008 to form a system on chip (SoC).
[0159] The electronic device can further include an input / output (I / O) device 1012. The I / O device 1012 can include a customer interface to enable a customer to interact with the electronic device; a peripheral component interface to enable peripheral components to also interact with the electronic device. In some implementations, the electronic device also includes a sensor to determine at least one of environmental conditions and location information related to the electronic device.
[0160] In some implementations, the customer interface can include, but is not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., a light emitting diode flash), and a keypad.
[0161] In some implementations, the peripheral component interface can include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.
[0162] In some implementations, the sensor can include, but is not limited to, a gyro sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit can also be part of or interact with the network interface 1010 to communicate with components of a positioning network (e.g., Global Positioning System (GPS) satellites).
[0163] It can be appreciated that the structure illustrated in the implementations of the present application does not constitute a specific limitation on the electronic device. In other implementations of the present application, the electronic device can include more or fewer components than illustrated, or combine certain components, or split certain components, or different arrangement of components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0164] The program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system that has a processor, such as, for example; a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0165] The program code can be implemented in a high level procedural or object oriented programming language to communicate with a processing system. The program code can also be implemented in assembly or machine language, if desired. In fact, the mechanisms described herein are not limited in scope to any particular programming language. In any case, the language can be a compiled or interpreted language.
[0166] One or more aspects of at least one implementation can be implemented by representative instructions stored on a computer-readable storage medium that represents various logic within the processor, which when read by a machine causes the machine to fabricate logic to perform the techniques described herein. Such representations, known as "IP cores" can be stored on a tangible, computer readable storage medium and supplied to various customers or manufacturing facilities to load into the fabrication machines that make the logic or processor.
[0167] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer readable storage medium can be any available media that can be used to store data and include one or more of a magnetic disk, an optical disk, a solid state memory, and the like. The computer program includes program instructions. The program instructions are executed by an electronic device to implement the processing method of the above sequence.
[0168] The embodiments of the present application further provide a computer program product including instructions. The computer program product can be a software or program product including computer program / instructions, which can be run on an electronic device or stored in any available medium. When the computer program product is run on at least one electronic device, the at least one electronic device is caused to execute the processing method of the above sequence.
[0169] It should be noted that in the drawings, some structural or methodological features can be shown in particular arrangements and / or orders. However, it should be understood that such particular arrangements and / or orders can not be required. Instead, these features can be arranged in a different manner and / or order than shown in the illustrative drawings, in some implementations. Additionally, the inclusion of a structural or methodological feature in a particular drawing does not imply that such feature is required in all implementations, and the features can be excluded or combined with other features in some implementations.
[0170] It should be noted that the terms "first", "second", and so on are used only to distinguish descriptions, and cannot be understood as indicating or implying relative importance.
[0171] It should be noted that in the drawings, some structural or methodological features can be shown in particular arrangements and / or orders. However, it should be understood that such particular arrangements and / or orders can not be required. Instead, these features can be arranged in a different manner and / or order than shown in the illustrative drawings, in some implementations. Additionally, the inclusion of a structural or methodological feature in a particular drawing does not imply that such feature is required in all implementations, and the features can be excluded or combined with other features in some implementations.
[0172] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it should be understood that the foregoing is intended to be illustrative only and not to be limiting. Many variations in form and detail can be apparent to a person of ordinary skill in the art without departing from the spirit and scope of the application.
Claims
1. A method for processing a sequence, applied to an electronic device, comprising: The method comprises: receiving a local sequence acquisition request, and applying for a current local sequence from a database according to the local sequence acquisition request; in a case where a sequence value used by the current local sequence reaches a first threshold, determining a new local cache window value of a next-applied local sequence according to a first preset rule; and determining new configuration parameters of the next-applied local sequence according to a second preset rule, comprising: determining whether a primary key number used by the current local sequence reaches a second threshold; if yes, updating configuration parameters of the sequence, and taking the updated configuration parameters as the new configuration parameters of the next-applied local sequence; if no, taking original configuration parameters of the sequence as the new configuration parameters of the next-applied local sequence; or determining whether a primary key number used by the current local sequence reaches a second threshold; if yes, determining whether a remaining processing time of a service processed using the current local sequence is less than a first time threshold; if yes, taking original configuration parameters of the sequence as the new configuration parameters of the next-applied local sequence; if no, updating configuration parameters of the sequence, and taking the updated configuration parameters as the new configuration parameters of the next-applied local sequence; acquiring a new local sequence from the database according to the new local cache window value and the new configuration parameters.
2. The method of processing a sequence according to claim 1, wherein, Determining a new local cache window value of a next-applied local sequence according to a first preset rule comprises: determining whether a window adjustment factor is less than a preset adjustment factor, the window adjustment factor being data related to a consumption time of a local sequence; if yes, increasing an initial local cache window value, and determining the new local cache window value according to the increased initial local cache window value; if no, taking the initial local cache window value as the new local cache window value.
3. The method of processing a sequence according to claim 2, wherein, Determining the window adjustment factor comprises: acquiring a first consumption time at which a sequence value used by the current local sequence reaches a first threshold, and a second consumption time of applying for the current local sequence from the database; determining the window adjustment factor according to the first consumption time and the second consumption time.
4. The method of processing a sequence according to claim 3, wherein, The window adjustment factor is determined according to the following formula: β=T1 / T2 wherein β is the window adjustment factor, T1 is the first consumption time, and T2 is the second consumption time.
5. The method of processing sequences according to any one of claims 2 to 4, wherein, Increasing the initial local cache window value and determining the new local cache window value according to the increased initial local cache window value comprises: multiplying the initial local cache window value by a preset adjustment coefficient to obtain the new local cache window value, the preset adjustment coefficient being greater than 1.
6. The method of processing a sequence according to claim 5, wherein, The preset adjustment coefficient is 2.
7. The method of processing a sequence according to claim 6, wherein, The first threshold is 99% of an initial local cache window value of the local sequence.
8. The method of processing a sequence according to claim 7, wherein, The second threshold is 90% of a maximum value of the primary key number available for the current local sequence.
9. The method of processing a sequence according to claim 7, wherein, The first time threshold is 30 minutes, and the second threshold is 90% of a maximum value of the primary key number available for the current local sequence.
10. The method of processing a sequence according to any one of claims 7 to 9, wherein, The configuration parameter comprises a prefix of the primary key number and a length of the primary key number, and the configuration parameter of the updating sequence comprises: modifying the prefix of the primary key number and / or modifying the length of the primary key number.
11. The method of processing a sequence according to claim 10, wherein, The modification of the length of the primary key number comprises adding 1 to the length of the primary key number.
12. The method of processing a sequence according to claim 11, wherein, The method further comprises: The initial value of the primary key number of the new local sequence is 1 plus the maximum value of the primary key number available for the current local sequence.
13. The method of processing a sequence according to claim 12, wherein, The configuration parameter is updated by a non-relational database.
14. A processing device of a sequence, characterized by, The processing device comprises: A first processing module configured to receive a local sequence acquisition request, and apply for a current local sequence from a database according to the local sequence acquisition request; A second processing module configured to, in a case where a sequence value used by the current local sequence reaches a first threshold value of an initial local cache window value of a local sequence, determine a new local cache window value of a next-applied local sequence according to a first preset rule; A third processing module configured to determine a new configuration parameter of the next-applied local sequence according to a second preset rule, comprising: judging whether a primary key number used by the current local sequence reaches a second threshold value; if yes, updating the configuration parameter of the sequence, and taking the updated configuration parameter as the new configuration parameter of the next-applied local sequence; if no, taking the original configuration parameter of the sequence as the new configuration parameter of the next-applied local sequence; or judging whether the primary key number used by the current local sequence reaches the second threshold value; if yes, judging whether a remaining processing time of a business processed using the current local sequence is less than a first time threshold value; if yes, taking the original configuration parameter of the sequence as the new configuration parameter of the next-applied local sequence; if no, updating the configuration parameter of the sequence, and taking the updated configuration parameter as the new configuration parameter of the next-applied local sequence; A fourth processing module configured to acquire a new local sequence from the database according to the new local cache window value and the new configuration parameter.
15. An electronic device, comprising: comprise: a memory configured to store a computer program, the computer program comprising program instructions; a processor configured to execute the program instructions to cause the electronic device to perform the sequence processing method according to any one of claims 1-13.
16. A computer readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program comprising program instructions, and the program instructions are run by an electronic device to cause the electronic device to perform the sequence processing method according to any one of claims 1-13.
17. A computer program product, characterised in that, The computer program / instructions are executed by an electronic device to implement the sequence processing method according to any one of claims 1-13.
Citation Information
Patent Citations
Cache management method and device
CN108153890A
Serial number value generation method and device, electronic equipment and storage medium
CN114722042A