Supercharge Your Innovation With Domain-Expert AI Agents!

A method of building a distributed lock for a redis database

A distributed lock and database technology, applied in the field of building distributed locks for Redis databases, to achieve high availability

Active Publication Date: 2021-04-27
SICHUAN XW BANK CO LTD
View PDF6 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0027] The present invention provides a method for constructing a distributed lock for a Redis database to reduce the risk of deadlock, solve problems such as early release of locks, improve concurrency performance, and achieve high availability (High Availability)

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
  • A method of building a distributed lock for a redis database
  • A method of building a distributed lock for a redis database

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0058] like figure 2 Shown the present invention builds the method for the distributed lock of Redis database, comprises:

[0059] A. Create a delay queue:

[0060]A1. Create a dead letter switch of type direct in RabbitMQ;

[0061] A2. Create a dead-letter queue for storing dead-letter messages, and the dead-letter switch and the dead-letter queue are bound through corresponding routing keys;

[0062] A3. Create a direct switch with type direct;

[0063] A4. Create a distributed lock queue for storing distributed lock information, and bind it with the dead letter queue through the corresponding routing key. The dead letter switch will find the dead letter queue where the dead letter message is stored according to the routing key ; Set the survival time of the message to 30 seconds.

[0064] B. Define a tool class based on Redssion for acquiring distributed locks and releasing distributed locks. There are four methods in the tool class, namely:

[0065] tryLock method: ...

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 present invention relates to the method for building the distributed lock that is used for Redis database, comprises: A. create dead letter exchange and directly connected exchange in RabbitMQ, and create dead letter queue and distributed lock queue, dead letter queue and dead letter exchange Binding, the distributed lock queue is bound to the dead letter switch and the directly connected switch respectively; B. Define the tool class based on Redssion for acquiring and releasing the distributed lock; C. Define the consumer of the dead letter queue D. Call the lock method in the tool class to get the result of whether the lock is successful; E. If the lock is successful, execute the business code; if the lock fails, exit and execute the business code; F. Release the lock. The present invention can meet the performance requirements in high concurrency scenarios, and solves the problems of the lock expiration time mechanism based on the Redis database and the early release of locks caused by the expiration time setting being too long or too short, and realizes high availability.

Description

technical field [0001] The invention relates to a method for constructing a distributed lock in a distributed system, in particular to a method for constructing a distributed lock for a Redis database. Background technique [0002] In the distributed application scenario, sometimes it is necessary to ensure that a resource can only be modified by the same operator at the same time, so the concept and technology of distributed locks are introduced. In order to implement distributed locks, several commonly used methods are: [0003] 1. Realize distributed lock based on database: [0004] step: [0005] 1) Create a lock table in the database to record the locks held by each thread; [0006] 2) When acquiring the lock, add a record to the lock table; [0007] 3) When releasing the lock, delete this record; [0008] shortcoming: [0009] 1) The performance cannot meet the demands of high concurrency scenarios; [0010] 2) In order to improve availability and solve single-p...

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 Patents(China)
IPC IPC(8): G06F16/23
CPCG06F16/2343
Inventor 李长彬
Owner SICHUAN XW BANK CO LTD
Features
  • R&D
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More