CN109948012B - Serial number generation method and device and storage medium - Google Patents

Serial number generation method and device and storage medium Download PDF

Info

Publication number
CN109948012B
CN109948012B CN201910194473.2A CN201910194473A CN109948012B CN 109948012 B CN109948012 B CN 109948012B CN 201910194473 A CN201910194473 A CN 201910194473A CN 109948012 B CN109948012 B CN 109948012B
Authority
CN
China
Prior art keywords
serial number
identification information
service program
generating
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910194473.2A
Other languages
Chinese (zh)
Other versions
CN109948012A (en
Inventor
李明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN201910194473.2A priority Critical patent/CN109948012B/en
Publication of CN109948012A publication Critical patent/CN109948012A/en
Application granted granted Critical
Publication of CN109948012B publication Critical patent/CN109948012B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The application relates to a method, a device and a storage medium for generating a serial number, comprising the following steps: when a serial number generation request is received, acquiring a current service program identifier for generating the serial number; judging whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number; and if not, generating the serial number according to the current service program identifier. The monotone increasement of the generated serial number is ensured, and the efficiency of generating the serial number is improved.

Description

Serial number generation method and device and storage medium
Technical Field
The present application belongs to the field of computer software applications, and in particular, to a method and an apparatus for generating a serial number, and a storage medium.
Background
With the development of internet technology, people are more and more common in using the internet. The number of terminals communicating with the server through the network is increasing. In order to facilitate the distinction management of the huge communication information, the related communication information needs to be distinguished and identified. For example, it is necessary to identify sessions between different clients and a server, or to identify sessions established between the same client and the server at different times, or to identify friends circling articles published by different clients and friends circling articles published by the same client at different times.
It is generally desirable to uniquely identify the associated communication by generating a non-repeating serial number. Such as generating a unique, non-repeating conversation or article identification to uniquely identify a conversation or article. In the related art, the serial number is generated using an autonomy key of MYSQL or similar database. Due to the fact that the database reading and writing performance is limited, the database reading and writing performance can become a system bottleneck when the database is used at high frequency, and after the database is used for a period of time, the situation of numerical value inversion can occur, the problem of repetition of the generated serial number is caused, and therefore the efficiency of generating the serial number is reduced.
Disclosure of Invention
In order to solve the problem of repeated generated serial numbers in the related art, the application discloses a serial number generation method, a serial number generation device and a storage medium, wherein whether the service program of a data structure server is subjected to master-slave switching is detected by comparing the service program identification of the master service program generating the serial numbers, and the serial number is prevented from backing or repeating in an extreme case by jumping the serial number, so that the monotonous increment of the generated serial numbers is ensured, and the serial number generation efficiency is improved.
According to a first aspect of an embodiment of the present application, a method for generating a serial number is provided, including:
when a serial number generation request is received, acquiring a current service program identifier for generating the serial number;
judging whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number;
and if not, generating the serial number according to the current service program identifier.
Optionally, the generating the serial number according to the current service program identifier includes:
and generating the serial number according to the current service program identification and the current system time.
Optionally, the serial number includes first identification information and second identification information;
further, the generating the serial number according to the current service program identifier and the current system time includes:
and determining the first identification information according to the current service program identification, determining the second identification information according to the current system time, and generating the serial number according to the determined first identification information and the second identification information.
Optionally, the serial number includes first identification information and second identification information;
further, if the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number, determining the first identification information of the current serial number according to the same service program identifier, and performing an increment operation on the second identification information of the last generated serial number to determine the second identification information of the current serial number;
and determining the current serial number according to the first identification information and the second identification information of the determined current serial number.
Optionally, the incrementing the second identification information of the last generated serial number to determine the second identification information of the current serial number includes:
acquiring a preset increasing numerical value;
and linearly superposing the second identification information of the last generated serial number and the preset addition value to obtain the second identification information of the current serial number.
Optionally, the determining the second identification information according to the current system time includes:
acquiring the current system time;
converting the time format of the current system time into a first format;
multiplying the current system time in the first format by a preset coefficient to obtain third identification information; and
and selecting a numerical value of a preset digit from the third identification information as the second identification information.
Optionally, the first format includes: the timestamp format.
Optionally, the serial number is a character string corresponding to a key-value, the first identification information indicates the current service program identification of the current main service program in which the key value of the serial number is located, and the second identification information indicates the number of times that the same main service program is continuously used for generating the serial number.
Optionally, the serial number is the character string of 16 bytes, and the first identification information and the second identification information are 8 bytes.
According to a second aspect of the embodiments of the present application, there is provided an apparatus for generating a serial number, including:
an acquisition unit configured to acquire, when receiving a sequence number generation request, a current service program identifier for generating the sequence number;
a judging unit configured to judge whether the current service program identifier used for generating the serial number is the same as a last service program identifier used for generating the serial number; and
and the serial number generating unit is configured to generate the serial number according to the current service program identification if the serial numbers are different.
Optionally, the generating the serial number according to the current service program identifier includes:
and generating the serial number according to the current service program identification and the current system time.
Optionally, the serial number includes first identification information and second identification information;
further, the generating the serial number according to the current service program identifier and the current system time includes:
and determining the first identification information according to the current service program identification, determining the second identification information according to the current system time, and generating the serial number according to the determined first identification information and the second identification information.
Optionally, the serial number includes first identification information and second identification information;
further, if the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number, determining the first identification information of the current serial number according to the same service program identifier, and performing an increment operation on the second identification information of the last generated serial number to determine the second identification information of the current serial number;
and determining the current serial number according to the first identification information and the second identification information of the determined current serial number.
Optionally, the incrementing the second identification information of the last generated serial number to determine the second identification information of the current serial number includes:
acquiring a preset increasing numerical value;
and linearly superposing the second identification information of the last generated serial number and the preset addition value to obtain the second identification information of the current serial number.
Optionally, the determining the second identification information according to the current system time includes:
acquiring the current system time;
converting the time format of the current system time into a first format;
multiplying the current system time in the first format by a preset coefficient to obtain third identification information; and
and selecting a numerical value of a preset digit from the third identification information as the second identification information.
Optionally, the first format includes: the timestamp format.
Optionally, the serial number is a character string corresponding to a key-value, the first identification information indicates the current service program identification of the current main service program in which the key value of the serial number is located, and the second identification information indicates the number of times that the same main service program is continuously used for generating the serial number.
Optionally, the serial number is the character string of 16 bytes, and the first identification information and the second identification information are 8 bytes.
According to a third aspect of the embodiments of the present application, there is provided a serial number generation control apparatus including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to perform any one of the above-mentioned serial number generation methods.
According to a fourth aspect of embodiments of the present application, there is provided a non-transitory computer-readable storage medium, wherein instructions, when executed by a processor of a mobile terminal, enable the mobile terminal to perform a method for generating a serial number, the method including any one of the methods for generating a serial number described above.
According to a fifth aspect of embodiments of the present application, there is provided a computer program product comprising a computer program product, the computer program comprising program instructions that, when executed by a mobile terminal, cause the mobile terminal to perform the steps of the above-described method for generating a serial number.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
(1) when a sequence number generation request is received, a current service program identifier for generating a sequence number is acquired. And judging whether the current service program identification used for generating the serial number is the same as the last service program identification used for generating the serial number. And if the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, generating the serial number according to the current service program identifier. Whether the service program of the data structure server is subjected to master-slave switching or not is detected by comparing the service program identification of the master service program generating the serial number. Therefore, the monotone increasement of the generated serial number is ensured, and the efficiency of generating the serial number is improved.
(2) When a sequence number generation request is received, a current service program identifier for generating a sequence number is acquired. And judging whether the current service program identification used for generating the serial number is the same as the last service program identification used for generating the serial number. And if the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, generating the serial number according to the current service program identifier and the current system time. And if the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number, generating the serial number according to the same service program identifier and the second identification information of the serial number generated last time. Whether the service program of the data structure server is subjected to master-slave switching or not is detected by comparing the service program identification of the master service program generating the serial number, and the serial number is prevented from returning or repeating in an extreme case by jumping the serial number, so that the monotone increasing property of the generated serial number is ensured, and the efficiency of generating the serial number is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
FIG. 1 is a flow diagram illustrating a method of generating a sequence number in accordance with an exemplary embodiment;
FIG. 2 is a block diagram illustrating a system for generating serial numbers in accordance with an exemplary embodiment;
FIG. 3 is a flow diagram illustrating a method of generating a sequence number in accordance with an exemplary embodiment;
FIG. 4 is a block diagram illustrating an apparatus for generating a serial number in accordance with an exemplary embodiment;
FIG. 5 is a block diagram illustrating an apparatus to perform a method of generating a serial number in accordance with an example embodiment;
fig. 6 is a block diagram illustrating an apparatus that performs a method of generating a serial number according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
Redis is a key-value (key-value) memory storage system that can be used as a data structure server, cache, and message queue agent. And data types such as character strings, hash tables, lists, collections, ordered collections, bitmaps, Hyperlogs and the like are supported. Because the redis has higher read-write performance, the application of the redis is more and more extensive.
In the use process of the redis, in order to improve the reliability of the redis, a master-slave service program/process is set in different servers, and the master-slave service program/process is managed by a monitoring module. When the main service program/process has a fault, the monitoring module switches the slave service program/process into the main service program/process and sends a notification message to each service network element needing to be accessed, so that each service network element modifies the stored IP address of the main service program/process, and the service network element can access the switched main service program/process according to the modified Internet protocol address of the main service program/process.
The serial number is a character string of key-value storage. In a distributed system, strings are quickly queried from a data structure server, such as redis, by key values.
Fig. 1 is a flow diagram illustrating a method of generating a sequence number in accordance with an example embodiment. The following is an example in which the method is applied to a serial number generation system. The serial number generation system comprises a terminal and a server. Various applications may be installed and run on the terminal, and may communicate with the server through the internet. Specifically, referring to fig. 2, fig. 2 is a schematic structural diagram illustrating a serial number generation system according to an exemplary embodiment, where the serial number generation system includes a terminal 201 and a server 202. The embodiment of the method for generating a sequence number shown in fig. 1 describes the steps of generating a monotonically increasing sequence number, which is applied to the terminal 201 and the server 202. The method comprises the following steps:
in step S101, when a sequence number generation request is received, a current service program identifier for generating the sequence number is acquired.
In this step, when receiving a serial number generation request issued by the terminal 201, the server 202 acquires a current service program identification for generating the serial number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions. For example, the current service identification of the host service that the server 202 obtained for generating the serial number is 10937.
In step S102, it is determined whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number.
In this step, the server 202 determines whether the current service program identification used to generate the serial number is the same as the last service program identification used to generate the serial number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions. For example, the last service program that server 202 obtained in memory the main service program used to generate the serial number is identified as 12767. Server 202 compares current service identification 10937 with last service identification 12767 and determines whether the current service identification used to generate the sequence number is the same as the last service identification used to generate the sequence number.
In step S103, if the service program identifiers are not the same, the serial number is generated according to the current service program identifier.
In this step, if the current service program identifier used to generate the serial number is not the same as the last service program identifier used to generate the serial number, the server 202 generates the serial number from the current service program identifier. Then, the server 202 returns the generated serial number to the terminal 201. For example, when the server 202 compares the current service program identifier 10937 with the last service program identifier 12767 and determines that the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, the serial number is generated according to the current service program identifier 10937.
According to an embodiment of the present application, when a serial number generation request is received, a current service program identification for generating a serial number is acquired. And judging whether the current service program identification used for generating the serial number is the same as the last service program identification used for generating the serial number. And if the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, generating the serial number according to the current service program identifier. Whether the service program of the data structure server is subjected to master-slave switching or not is detected by comparing the service program identification of the master service program generating the serial number. Therefore, the monotone increasement of the generated serial number is ensured, and the efficiency of generating the serial number is improved.
Fig. 3 is a flowchart illustrating a method of generating a serial number, which is a key-value corresponding character string, according to an exemplary embodiment, including: first identification information and second identification information. The first identification information represents a current service program identification of a current main service program where a key value of the serial number is located, and the second identification information represents the number of times that the same main service program is continuously used for generating the serial number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions. The method comprises the following steps:
in step S301, when a sequence number generation request is received, a current service program identifier for generating the sequence number is acquired.
In this step, when a sequence number generation request is received, a current service identification for generating a sequence number is acquired. For example, the sequence number is a 16-byte character string. The current service identification is the service identification of the main service used to generate the current sequence number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions.
The serial number generation request may be that when a user performs a relevant operation (for example, login) on the client interface, which requires to establish communication with the server, the terminal running the client requests the server to create a session and requests to obtain a serial number uniquely identifying the created session. Alternatively, the user performs a related authentication operation (for example, a real-name authentication operation) based on the terminal, and the terminal sends a corresponding authentication operation request to the server and requests to acquire a serial number uniquely identifying the authentication operation request. In this embodiment, the use scenario in which the terminal sends the sequence number generation request is not limited.
In step S302, it is determined whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number.
This step is identical to step S102 in fig. 1, and will not be described here.
In step S303, if the service identifier is not the same as the current service identifier, the serial number is generated according to the current service identifier and the current system time.
In this step, if the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, the serial number is generated according to the current service program identifier and the current system time.
Specifically, the serial number includes first identification information and second identification information. And determining first identification information according to the current service program identification. The value of the preset number of bits may be selected from the current service program identifier as the first identifier information. For example, the first 8 bytes of value is selected from the current service program identifier as the first identifier information.
And determining second identification information according to the current system time. It may be that the current system time is acquired. The time format of the current system time is converted to a first format. The first format includes: timestamp format, plaintext format. And multiplying the current system time in the first format by a preset coefficient to obtain third identification information. The third identification information is an integer. And selecting a numerical value of a preset digit from the third identification information as second identification information. For example, the system time is represented by ts _ ms after the time format is converted into the millisecond timestamp format. The third identification information is ts _ ms × 1000000. And selecting the numerical value of the first 8 bytes from the third identification information as second identification information. It is to be understood that the manner in which the predetermined number of bits is selected should not be construed as limiting the present application.
And generating a serial number according to the determined first identification information and the second identification information. The first identification information and the second identification information may be used as part of a serial number to generate the serial number. For example, the first identification information is set as the high byte of the sequence number, and the second identification information is set as the low byte of the sequence number.
In step S304, if the serial numbers are the same, the serial numbers are generated according to the same service program identifier and the second identification information of the serial numbers generated last time.
In this step, if the current service program identifier used to generate the serial number is the same as the last service program identifier used to generate the serial number, the serial number is generated based on the same service program identifier and the second identification information of the last generated serial number.
Specifically, the serial number includes first identification information and second identification information. And determining first identification information of the current serial number according to the same service program identification. The value of the preset number of bits may be selected from the same service program identifier as the first identifier information. For example, the first 8 bytes of value is selected from the same service program identifier as the first identifier information.
Performing an increment operation on the second identification information of the last generated serial number to determine the second identification information of the current serial number. It may be that a preset incremental value is obtained. And carrying out incremental processing on the second identification information of the last generated serial number and a preset incremental value to obtain the second identification information of the current serial number. It is understood that the increment may be a linear increment, or may be other increment manners such as an exponential increment or an geometric increment, and should not be construed as a limitation to the present application.
And determining the current serial number according to the first identification information and the second identification information of the determined current serial number. The first identification information and the second identification information may be used as part of a serial number to generate the serial number. For example, the first identification information is set as the high byte of the sequence number, and the second identification information is set as the low byte of the sequence number.
If the current service program identification of the current main service program used for generating the serial number is different from the last service program identification used for generating the serial number, the fact that the master-slave service program is switched in the time interval of calling the main service program twice to generate the serial number indicates that the master-slave service program is switched in the redis. The switching of the master-slave service program may be the switching of a master-slave program, a routine or a process, or the switching of a master-slave node in a redis cluster. During the switching of the redis master-slave service program, some data may not be synchronized to the slave service program in time, and if the sequence number is directly incremented at this time, for example, by 1, the sequence number allocated by the old master service program may be reused, which violates the principle of incrementability.
Normally, the time consumed for switching between master and slave service procedures is >1ms, and the incrementability of the generated sequence number can be ensured as long as the number of the generated sequence numbers in 1ms is ensured to be less than 1000000, namely QPS is ensured to be less than 10 hundred million/second. The number of the generated serial numbers in the current redis 1ms is absolutely smaller than the value, so that the monotonous increment of the generated serial numbers can be ensured.
According to an embodiment of the present application, when a serial number generation request is received, a current service program identification for generating a serial number is acquired. And judging whether the current service program identification used for generating the serial number is the same as the last service program identification used for generating the serial number. And if the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, generating the serial number according to the current service program identifier and the current system time. And if the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number, generating the serial number according to the same service program identifier and the second identification information of the serial number generated last time. Whether the service program of the data structure server is subjected to master-slave switching or not is detected by comparing the service program identification of the master service program generating the serial number, and the serial number is prevented from returning or repeating in an extreme case by jumping the serial number, so that the monotone increasing property of the generated serial number is ensured, and the efficiency of generating the serial number is improved.
Fig. 4 is a block diagram illustrating a serial number generation apparatus according to an example embodiment. As shown in fig. 4, the apparatus 40 includes: an acquisition unit 401, a judgment unit 402, and a serial number generation unit 403.
An obtaining unit 401 configured to obtain, when receiving a sequence number generation request, a current service program identifier used for generating the sequence number.
The unit is configured to acquire a current service identification for generating a sequence number when receiving a sequence number generation request. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions.
A determining unit 402 configured to determine whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number.
The unit is configured to determine whether a current service identification used to generate the sequence number is the same as a last service identification used to generate the sequence number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions.
A serial number generating unit 403, configured to generate the serial number according to the current service program identifier if the serial numbers are not the same.
The unit is configured to generate the sequence number according to a current service identity if the current service identity used to generate the sequence number is not the same as a last service identity used to generate the sequence number.
In an alternative embodiment of the present application, the serial number is a key-value corresponding character string, including: first identification information and second identification information. The first identification information represents a current service program identification of a current main service program where a key value of the serial number is located, and the second identification information represents the number of times that the same main service program is continuously used for generating the serial number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions.
When a sequence number generation request is received, a current service program identifier for generating a sequence number is acquired. For example, the sequence number is a 16-byte character string. The current service identification is the service identification of the main service used to generate the current sequence number. It is understood that a service refers to a program, routine, process, or node in a redis cluster that performs specified system functions.
The serial number generation request may be that when a user performs a relevant operation (for example, login) on the client interface, which requires to establish communication with the server, the terminal running the client requests the server to create a session and requests to obtain a serial number uniquely identifying the created session. Alternatively, the user performs a related authentication operation (for example, a real-name authentication operation) based on the terminal, and the terminal sends a corresponding authentication operation request to the server and requests to acquire a serial number uniquely identifying the authentication operation request. In this embodiment, the use scenario in which the terminal sends the sequence number generation request is not limited.
And judging whether the current service program identification used for generating the serial number is the same as the last service program identification used for generating the serial number.
And if the current service program identifier used for generating the serial number is not the same as the last service program identifier used for generating the serial number, generating the serial number according to the current service program identifier and the current system time.
Specifically, the serial number includes first identification information and second identification information. And determining first identification information according to the current service program identification. The value of the preset number of bits may be selected from the current service program identifier as the first identifier information. For example, the first 8 bytes of value is selected from the current service program identifier as the first identifier information.
And determining second identification information according to the current system time. It may be that the current system time is acquired. The time format of the current system time is converted to a first format. The first format includes: timestamp format, plaintext format. And multiplying the current system time in the first format by a preset coefficient to obtain third identification information. The third identification information is an integer. And selecting a numerical value of a preset digit from the third identification information as second identification information. For example, the system time is represented by ts _ ms after the time format is converted into the millisecond timestamp format. The third identification information is ts _ ms × 1000000. And selecting the numerical value of the first 8 bytes from the third identification information as second identification information. It is to be understood that the manner in which the predetermined number of bits is selected should not be construed as limiting the present application.
And generating a serial number according to the determined first identification information and the second identification information. The first identification information and the second identification information may be used as part of a serial number to generate the serial number. For example, the first identification information is set as the high byte of the sequence number, and the second identification information is set as the low byte of the sequence number.
And if the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number, generating the serial number according to the same service program identifier and the second identification information of the serial number generated last time.
Specifically, the serial number includes first identification information and second identification information. And determining first identification information of the current serial number according to the same service program identification. The value of the preset number of bits may be selected from the same service program identifier as the first identifier information. For example, the first 8 bytes of value is selected from the same service program identifier as the first identifier information.
Performing an increment operation on the second identification information of the last generated serial number to determine the second identification information of the current serial number. It may be that a preset incremental value is obtained. And carrying out incremental processing on the second identification information of the last generated serial number and a preset incremental value to obtain the second identification information of the current serial number. It is understood that the increment may be a linear increment, or may be other increment manners such as an exponential increment or an geometric increment, and should not be construed as a limitation to the present application.
And determining the current serial number according to the first identification information and the second identification information of the determined current serial number. The first identification information and the second identification information may be used as part of a serial number to generate the serial number. For example, the first identification information is set as the high byte of the sequence number, and the second identification information is set as the low byte of the sequence number.
Fig. 5 is a block diagram illustrating an apparatus 1200 for performing a method of generating a sequence number, according to an example embodiment. For example, the apparatus 1200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 5, apparatus 1200 may include one or more of the following components: a processing component 1202, a memory 1204, a power component 1206, a multimedia component 1208, an audio component 1210, an input/output (I/O) interface 1212, a sensor component 1214, and a communications component 1216.
The processing component 1202 generally controls overall operation of the apparatus 1200, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 1202 may include one or more processors 1220 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 1202 can include one or more modules that facilitate interaction between the processing component 1202 and other components. For example, the processing component 1202 can include a multimedia module to facilitate interaction between the multimedia component 1208 and the processing component 1202.
The memory 1204 is configured to store various types of data to support operation at the device 1200. Examples of such data include instructions for any application or method operating on the device 1200, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 1204 may be implemented by any type or combination of volatile or non-volatile memory devices 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 memory, flash memory, magnetic or optical disks.
A power supply component 1206 provides power to the various components of the device 1200. Power components 1206 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for apparatus 1200.
The multimedia components 1208 include a screen that provides an output interface between the device 1200 and a 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 touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1208 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 1200 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
Audio component 1210 is configured to output and/or input audio signals. For example, audio component 1210 includes a Microphone (MIC) configured to receive external audio signals when apparatus 1200 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 1204 or transmitted via the communication component 1216. In some embodiments, audio assembly 1210 further includes a speaker for outputting audio signals.
The I/O interface 1212 provides an interface between the processing component 1202 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 1214 includes one or more sensors for providing various aspects of state assessment for the apparatus 1200. For example, the sensor assembly 1214 may detect an open/closed state of the device 1200, the relative positioning of the components, such as a display and keypad of the apparatus 1200, the sensor assembly 1214 may also detect a change in the position of the apparatus 1200 or a component of the apparatus 1200, the presence or absence of user contact with the apparatus 1200, an orientation or acceleration/deceleration of the apparatus 1200, and a change in the temperature of the apparatus 1200. The sensor assembly 1214 may include a proximity sensor configured to detect the presence of a nearby object in the absence of any physical contact. The sensor assembly 1214 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1214 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communications component 1216 is configured to facilitate communications between the apparatus 1200 and other devices in a wired or wireless manner. The apparatus 1200 may access a wireless network based on a communication standard, such as WiFi, an operator network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 1216 receives the broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communications component 1216 further includes a Near Field Communication (NFC) module to facilitate short-range communications. 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.
In an exemplary embodiment, the apparatus 1200 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, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as memory 1204 comprising instructions, executable by processor 1220 of apparatus 1200 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, there is also provided a computer program product, including a computer program product, the computer program including program instructions, which, when executed by a mobile terminal, cause the mobile terminal to perform the iterative steps of the method for generating a serial number as described above: when a serial number generation request is received, acquiring a current service program identifier for generating the serial number; judging whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number; and if not, generating the serial number according to the current service program identifier.
Fig. 6 is a block diagram illustrating an apparatus 1300 for performing a method of generating a sequence number, according to an example embodiment. For example, the apparatus 1300 may be provided as a server. Referring to fig. 6, apparatus 1300 includes a processing component 1322, which further includes one or more processors, and memory resources, represented by memory 1332, for storing instructions, such as application programs, that may be executed by processing component 1322. The application programs stored in memory 1332 may include one or more modules that each correspond to a set of instructions. In addition, processing component 1322 is configured to execute instructions to perform the above-described information list display method.
The apparatus 1300 may also include a power component 1326 configured to perform power management for the apparatus 1300, a wired or wireless network interface 1350 configured to connect the apparatus 1300 to a network, and an input-output (I/O) interface 1358. The apparatus 1300 may operate based on an operating system stored in the memory 1332, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (14)

1. A method for generating a serial number, comprising:
when a serial number generation request is received, acquiring a current service program identifier for generating a serial number, wherein the current service program identifier is the service program identifier of the service program for generating the serial number;
judging whether the current service program identifier used for generating the serial number is the same as the last service program identifier used for generating the serial number, wherein the last service program identifier is the service program identifier of the service program used for generating the serial number last time;
if not, determining first identification information according to the current service program identification, determining second identification information according to the current system time, and generating a serial number according to the determined first identification information and the second identification information;
if the serial numbers are the same, determining first identification information of the current serial number according to the same service program identification, performing increment operation on second identification information of the serial number generated last time to determine the second identification information of the current serial number, and determining the current serial number according to the determined first identification information and the determined second identification information of the current serial number.
2. The method for generating a sequence number according to claim 1, wherein the incrementing the second identification information of the last generated sequence number to determine the second identification information of the current sequence number comprises:
acquiring a preset increasing numerical value;
and linearly superposing the second identification information of the last generated serial number and the preset addition value to obtain the second identification information of the current serial number.
3. The method for generating serial numbers according to claim 1, wherein the determining the second identification information according to the current system time comprises:
acquiring current system time;
converting the time format of the current system time into a first format;
multiplying the current system time in the first format by a preset coefficient to obtain third identification information; and
and selecting a numerical value of a preset digit from the third identification information as the second identification information.
4. The method of generating a serial number according to claim 3, wherein the first format comprises: the timestamp format.
5. The method according to claim 1, wherein the serial number is a character string corresponding to a key-value, the first identification information indicates the current service program identifier of a current main service program in which a key value of the serial number is located, and the second identification information indicates a number of times that the same main service program is continuously used to generate the serial number.
6. The method for generating a serial number according to claim 1, wherein the serial number is a 16-byte character string, and the first identification information and the second identification information are 8 bytes.
7. An apparatus for generating a serial number, comprising:
an acquisition unit configured to acquire, when receiving a serial number generation request, a current service program identifier for generating a serial number, the current service program identifier being a service program identifier of a service program currently used for generating the serial number;
a judging unit configured to judge whether the current service program identifier used for generating the serial number is the same as a last service program identifier used for generating the serial number, the last service program identifier being a service program identifier of a service program used for generating the serial number last time; and
a serial number generating unit, configured to determine first identification information according to the current service program identification if the service program identification is different from the current service program identification, determine second identification information according to the current system time, and generate a serial number according to the determined first identification information and the determined second identification information;
if the serial numbers are the same, determining first identification information of the current serial number according to the same service program identification, performing increment operation on second identification information of the serial number generated last time to determine the second identification information of the current serial number, and determining the current serial number according to the determined first identification information and the determined second identification information of the current serial number.
8. The apparatus for generating serial number according to claim 7, wherein said incrementing second identification information of the last generated serial number to determine second identification information of the current serial number comprises:
acquiring a preset increasing numerical value;
and linearly superposing the second identification information of the last generated serial number and the preset addition value to obtain the second identification information of the current serial number.
9. The apparatus for generating serial number according to claim 7, wherein said determining the second identification information according to the current system time comprises:
acquiring current system time;
converting the time format of the current system time into a first format;
multiplying the current system time in the first format by a preset coefficient to obtain third identification information; and
and selecting a numerical value of a preset digit from the third identification information as the second identification information.
10. The apparatus for generating a serial number according to claim 9, wherein the first format comprises: the timestamp format.
11. The apparatus according to claim 7, wherein the serial number is a character string corresponding to a key-value, the first identification information indicates the current service program identifier of a current main service program in which a key value of the serial number is located, and the second identification information indicates a number of times that the same main service program is used to generate the serial number continuously.
12. The apparatus for generating a serial number according to claim 7, wherein the serial number is a 16-byte character string, and the first identification information and the second identification information are 8 bytes.
13. A serial number generation control device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method of generating a serial number of any of the preceding claims 1-7.
14. A non-transitory computer readable storage medium, wherein instructions, when executed by a processor of a mobile terminal, enable the mobile terminal to perform a method of generating a serial number, the method comprising the method of generating a serial number according to any of claims 1 to 7.
CN201910194473.2A 2019-03-14 2019-03-14 Serial number generation method and device and storage medium Active CN109948012B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910194473.2A CN109948012B (en) 2019-03-14 2019-03-14 Serial number generation method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910194473.2A CN109948012B (en) 2019-03-14 2019-03-14 Serial number generation method and device and storage medium

Publications (2)

Publication Number Publication Date
CN109948012A CN109948012A (en) 2019-06-28
CN109948012B true CN109948012B (en) 2021-11-16

Family

ID=67009974

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910194473.2A Active CN109948012B (en) 2019-03-14 2019-03-14 Serial number generation method and device and storage medium

Country Status (1)

Country Link
CN (1) CN109948012B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110798358B (en) * 2019-11-05 2022-12-30 泰康保险集团股份有限公司 Distributed service identification method and device, computer readable medium and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011003085A (en) * 2009-06-19 2011-01-06 Sumitomo Mitsui Banking Corp Authentication system and authentication method
CN102131117A (en) * 2011-03-21 2011-07-20 深圳创维数字技术股份有限公司 Digital television program switching method, switching control device and set top box
CN102662632A (en) * 2012-03-14 2012-09-12 北京神州数码思特奇信息技术股份有限公司 Serial number generation method based on semaphore and generator.
CN103136047A (en) * 2011-11-30 2013-06-05 大唐联诚信息系统技术有限公司 Multithreading management method and framework
CN106657216A (en) * 2016-09-19 2017-05-10 腾讯征信有限公司 Serial number generation method and serial number generation device
CN107229555A (en) * 2017-05-04 2017-10-03 北京小度信息科技有限公司 Mark generating method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108243264A (en) * 2016-12-27 2018-07-03 中国移动通信有限公司研究院 A kind of sequence number generation method and system
CN109190361A (en) * 2018-08-14 2019-01-11 深圳市华旭科技开发有限公司 A kind of method, apparatus, system and readable storage medium that sequence number generates

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011003085A (en) * 2009-06-19 2011-01-06 Sumitomo Mitsui Banking Corp Authentication system and authentication method
CN102131117A (en) * 2011-03-21 2011-07-20 深圳创维数字技术股份有限公司 Digital television program switching method, switching control device and set top box
CN103136047A (en) * 2011-11-30 2013-06-05 大唐联诚信息系统技术有限公司 Multithreading management method and framework
CN102662632A (en) * 2012-03-14 2012-09-12 北京神州数码思特奇信息技术股份有限公司 Serial number generation method based on semaphore and generator.
CN106657216A (en) * 2016-09-19 2017-05-10 腾讯征信有限公司 Serial number generation method and serial number generation device
CN107229555A (en) * 2017-05-04 2017-10-03 北京小度信息科技有限公司 Mark generating method and device

Also Published As

Publication number Publication date
CN109948012A (en) 2019-06-28

Similar Documents

Publication Publication Date Title
CN109274510B (en) Message processing method, device, client, server and storage medium
CN107094094B (en) Application networking method and device and terminal
CN109388625B (en) Method and device for processing configuration file in multi-distributed file system
CN109814942B (en) Parameter processing method and device
WO2020020048A1 (en) Method and apparatus for updating group member data, and terminal, system and storage medium
CN108737588B (en) Domain name resolution method and device
CN112583896B (en) Session management method, session management device, electronic equipment, session management server and storage medium
CN111338971B (en) Application testing method and device, electronic equipment and storage medium
CN107276795B (en) Container-based information processing method and device, server and terminal
CN109948012B (en) Serial number generation method and device and storage medium
CN109245992B (en) Request processing method and device, electronic equipment and storage medium
CN110764847A (en) User information processing method and device, electronic equipment and storage medium
CN111221593A (en) Dynamic loading method and device
CN107885464B (en) Data storage method, device and computer readable storage medium
CN107172199B (en) State updating method and device of mobile terminal
CN107070816B (en) Application identification method and device and mobile terminal
CN106060104B (en) Application management method and device
CN114430370B (en) Method, device, equipment and storage medium for determining network slice
CN112651012B (en) Information processing method and device
CN112769677B (en) Data synchronization method, apparatus, electronic device, storage medium, and program product
CN110457084B (en) Loading method and device
CN111680248A (en) Method and device for generating batch number of message pushed
CN110995767B (en) Request processing method and device
CN110247828B (en) Identification code allocation method and device
CN111241134B (en) Data processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant