package com.jmdf.world;
import redis.clients.jedis.Jedis;
import java.util.HashMap;
import java.util.Map;
/**
* redis实现可重入锁,借助ThreadLocal
*/
public class RedisWithReentrantLock {
private ThreadLocal<Map> lockers = new ThreadLocal<>();
private Jedis jedis;
public RedisWithReentrantLock(Jedis jedis) {
this.jedis = jedis;
}
private boolean _lock(String key) {
return jedis.set(key, "", "nx", "ex"
redis实现可重入锁
最新推荐文章于 2024-05-20 14:16:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)