Linux blocking and non-blocking

1. Introduction to blocking and non-blocking block non-blocking fd = open(“/dev/xxx_dev”, O_RDWR); //open file in blocking mode fd = open(“/dev/xxx_dev”, O_RDWR | O_NONBLOCK); /* open in non-blocking mode */ 2. Waiting queue 1. Waiting for the head of the queue The biggest advantage of blocking access is that when the device file is inoperable, the […]

SpringBoot integrates Redis, and understanding of cache penetration, cache avalanche, cache breakdown, how to add locks to solve the problem of cache breakdown? How to add distributed locks in distributed cases

Article directory 1. Steps 2. Specific process 1. Introduce pom dependencies 2. Modify the configuration file 3. Unit testing 4. Test results 3. Redis running status 4. Practical application in the project 5. Locking solves the problem of cache breakdown Code one (there is a problem) Code two (problem solving) 6. New questions 7. Distributed […]

ReentrantLock source code analysis

Foreword Note: The source code of this article comes from JDK11 ReentrantLock is a reentrant lock in Java, which can be used to replace the traditional synchronized keyword for thread synchronization. Here are some comparisons with the synchronized keyword: name implementation reentrancy interruption fairness Does it support timeout Release lock ReentrantLock Java API level , […]

Class variables, class methods, code blocks, abstract classes, interfaces, and inner classes

After learning about encapsulation, inheritance, and polymorphism in object-oriented programming, I recently came into contact with several new knowledge points. Sort it out here, help yourself to review, and also record my learning experience. 1. Class variables and class methods Instance objects of the same class only share a template prototype, and do not share […]

Analysis of ReentrantLock lock and unlock

Analysis of the principle of ReentrantLock Speaking of ReentrantLock, we all know that it is a reentrant mutex based on AQS (AbstractQueuedSynchronizer). If we want to analyze ReentrantLock, we have to start with AbstractQueuedSynchronizer. Analysis of AbstractQueuedSynchronizer AbstractQueuedSynchronizer has an internal class Node, and the underlying layer maintains a doubly linked list to form a […]

13. Row lock range_lock analysis_a bit complicated

Directory 1 premise 1.1 Knowledge reserve 1.2 Related background of the lock: 1.3 What are the row lock granularities? 1.4 Locking rules 1.5 Index in range query 1.4 Data preparation 2. Case 1: Equivalence query gap lock 2.1 Effect 2.2 Principle 3. Case 2: non-unique index equivalent lock 3.1 Effect 3.2 Description 4. Case 2: […]