Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Identifier generation method and device based on Redis

A technology of identification and device identification, which is applied in the computer field, can solve the problems of multiple storage spaces, ID duplication, occupation, etc., and achieve the effects of strong disaster tolerance, reduced occupation, and shortened ID length

Pending Publication Date: 2020-09-22
CHINA CONSTRUCTION BANK
View PDF7 Cites 1 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0005] 1. Due to the synchronization problem between the master and slave in the master-standby mode of Redis, once the master is abnormal, when the slave is switched over during failover, the ID may be duplicated due to the master-standby consistency problem;
[0006] 2. The timestamp is generated based on the local clock of the working device. Therefore, when the clock of the working device is dialed back, the timestamp of the generated ID will also be rolled back. If the ID is still generated according to the timestamp after the rollback, it may There will be a problem of ID duplication;
[0007] 3. The 64-bit ID is redundant for most software systems, will take up too much storage space, and cannot be appropriately expanded according to the application scenario

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Identifier generation method and device based on Redis
  • Identifier generation method and device based on Redis
  • Identifier generation method and device based on Redis

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0078] Exemplary embodiments of the present invention are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.

[0079] see figure 1 , which shows a schematic flowchart of a Redis-based identification generation method according to an embodiment of the present invention, including the following steps:

[0080] S101: Receive an identifier generation request, and detect whether the current master database is running normally;

[0081] S102: If it is normal, set the active-standby swi...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses an identifier generation method and device based on Redis, and relates to the technical field of computers. A specific embodiment of the method comprises the steps of receivingan identifier generation request, and detecting whether a current main database runs normally or not; if so, setting the main / standby switching flag bit as a first numerical value, and generating anidentifier by utilizing the main database based on the sign bit, the first numerical value and the serial number; and if soothe current main database runs abnormally, setting the main / standby switching flag bit as a second numerical value, carrying out main / standby switching on the main database and a normally running standby database, and further generating an identifier by utilizing the standbydatabase based on the sign bit, the second numerical value and the serial number. According to the embodiment, the values of the main and standby switching flag bits are different when the main database or the standby database is used, so that the uniqueness and high availability of identifier generation are ensured, the disaster tolerance capability is high, and a single-point fault is avoided. By setting the idle bits, the ID length can be shortened, the occupation amount of the storage space is reduced, and subsequent dynamic expansion of other identification bits is facilitated.

Description

technical field [0001] The present invention relates to the field of computer technology, in particular to a Redis-based identification generation method and device. Background technique [0002] In a complex distributed system, it is often necessary to uniquely identify a large amount of data and messages, such as the contract number in the contract system, the serial number such as the loan number or bank card number in the core, mortgage, and collection system, etc. These unique identifications are Distributed ID. [0003] The current Redis-based distributed ID generation method usually uses Redis single-threaded features and expiration strategies to obtain IDs. The generated distributed IDs are 64 bits, as follows: use 41 bits to store time, accurate to milliseconds; use 12 bits to store logic points Fragment ID, the maximum fragment ID is 4095; if 10bit is used to store self-increasing ID, each node can generate up to 1024 IDs per millisecond. [0004] In the process ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F16/22G06F16/21
CPCG06F16/2272G06F16/21
Inventor 张鹏
Owner CHINA CONSTRUCTION BANK
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products