From 715abe114090916964281e3222605a12ec4f729a Mon Sep 17 00:00:00 2001
From: sxq <812980466@qq.com>
Date: 星期二, 22 六月 2021 16:31:41 +0800
Subject: [PATCH] 删除redislockmanager

---
 /dev/null |  170 --------------------------------------------------------
 1 files changed, 0 insertions(+), 170 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java
deleted file mode 100644
index 0688bb1..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package com.ruoyi.common.core.redis;
-
-import cn.hutool.core.lang.Assert;
-import cn.hutool.core.lang.Validator;
-import cn.hutool.core.util.StrUtil;
-import org.redisson.api.RCountDownLatch;
-import org.redisson.api.RLock;
-import org.redisson.api.RedissonClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * redis 閿佺鐞嗙被
- *
- * @author shenxinquan
- */
-@Component
-public class RedisLockManager {
-
-	@Autowired
-	private RedissonClient redissonClient;
-
-	/**
-	 * 閫氱敤閿�
-	 */
-	private final static Integer BASE_LOCK = 1;
-
-	/**
-	 * 鍏钩閿�
-	 */
-	private final static Integer FAIR_LOCK = 2;
-
-	/**
-	 * 瀛樻斁褰撳墠绾跨▼鑾峰彇閿佺殑绫诲瀷
-	 */
-	private final ThreadLocal<Integer> threadLocal = new ThreadLocal<>();
-
-	/**
-	 * 鑾峰彇閿�
-	 */
-	private RLock getLock(String key, Integer lockType) {
-		Assert.isTrue(StrUtil.isNotBlank(key), "key涓嶈兘涓虹┖");
-		threadLocal.set(lockType);
-		RLock lock;
-		if (BASE_LOCK.equals(lockType)) {
-			lock = redissonClient.getLock(key);
-		} else if (FAIR_LOCK.equals(lockType)) {
-			lock = redissonClient.getFairLock(key);
-		} else {
-			throw new RuntimeException("閿佷笉瀛樺湪!");
-		}
-		return lock;
-	}
-
-	/**
-	 * 鑾峰彇閿侊紙涓嶇敤璁剧疆瓒呮椂鏃堕棿锛屼竴鐩寸瓑寰咃級
-	 */
-	public boolean getLock(String key) {
-		RLock lock = getLock(key, BASE_LOCK);
-		return lock.tryLock();
-	}
-
-	/**
-	 * 璁剧疆杩囨湡鏃堕棿
-	 *
-	 * @param key
-	 * @param time       杩囨湡鏃堕棿
-	 * @param expireUnit 鏃堕棿鍗曚綅
-	 */
-	public boolean getLock(String key, long time, TimeUnit expireUnit) {
-		Assert.isTrue(time > 0, "杩囨湡鏃堕棿蹇呴』澶т簬0");
-		Assert.isTrue(Validator.isNotEmpty(expireUnit), "鏃堕棿鍗曚綅涓嶈兘涓虹┖");
-		RLock lock = getLock(key, BASE_LOCK);
-		try {
-			return lock.tryLock(time, expireUnit);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-			return false;
-		}
-	}
-
-	/**
-	 * 璁剧疆杩囨湡鏃堕棿
-	 *
-	 * @param key
-	 * @param waitTime   鑾峰彇閿佺瓑寰呮椂闂�
-	 * @param leaseTime  淇濈暀閿佺殑鏃堕棿
-	 * @param expireUnit 鏃堕棿鍗曚綅
-	 */
-	public boolean getLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) {
-		Assert.isTrue(waitTime > 0, "鑾峰彇閿佺瓑寰呮椂闂村繀椤诲ぇ浜�0");
-		Assert.isTrue(leaseTime > 0, "淇濈暀閿佺殑鏃堕棿蹇呴』澶т簬0");
-		Assert.isTrue(Validator.isNotEmpty(expireUnit), "鏃堕棿鍗曚綅涓嶈兘涓虹┖");
-		RLock lock = getLock(key, BASE_LOCK);
-		try {
-			return lock.tryLock(waitTime, leaseTime, expireUnit);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-			return false;
-		}
-	}
-
-
-	/**
-	 * 鑾峰彇璁℃暟鍣ㄩ攣
-	 *
-	 * @param key
-	 * @param count countDownLatch 鐨勬暟閲�
-	 */
-	public RCountDownLatch getCountDownLatch(String key, long count) {
-		Assert.isTrue(count >= 0, "count鏁伴噺蹇呴』澶т簬绛変簬0");
-		RCountDownLatch rCountDownLatch = redissonClient.getCountDownLatch(key);
-		rCountDownLatch.trySetCount(count);
-		return rCountDownLatch;
-	}
-
-	/**
-	 * 鑾峰彇鍏钩閿�
-	 *
-	 * @param key
-	 * @param waitTime   鑾峰彇閿佺瓑寰呮椂闂�
-	 * @param leaseTime  鎸佹湁閿佺殑鏃堕棿
-	 * @param expireUnit 鏃堕棿鍗曚綅
-	 * @return
-	 * @throws InterruptedException
-	 */
-	public boolean getFairLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) {
-		Assert.isTrue(waitTime > 0, "鑾峰彇閿佺瓑寰呮椂闂村繀椤诲ぇ浜�0");
-		Assert.isTrue(leaseTime > 0, "淇濈暀閿佺殑鏃堕棿蹇呴』澶т簬0");
-		Assert.isTrue(Validator.isNotEmpty(expireUnit), "鏃堕棿鍗曚綅涓嶈兘涓虹┖");
-		RLock lock = getLock(key, FAIR_LOCK);
-		try {
-			return lock.tryLock(waitTime, leaseTime, expireUnit);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-			return false;
-		}
-	}
-
-	/**
-	 * 鑾峰彇鍏钩閿�
-	 *
-	 * @param key
-	 * @param leaseTime  鎸佹湁閿佺殑鏃堕棿
-	 * @param expireUnit 鏃堕棿鍗曚綅
-	 */
-	public boolean getFairLock(String key, long leaseTime, TimeUnit expireUnit) {
-		Assert.isTrue(leaseTime > 0, "淇濈暀閿佺殑鏃堕棿蹇呴』澶т簬0");
-		Assert.isTrue(Validator.isNotEmpty(expireUnit), "鏃堕棿鍗曚綅涓嶈兘涓虹┖");
-		RLock lock = getLock(key, FAIR_LOCK);
-		try {
-			return lock.tryLock(leaseTime, expireUnit);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-			return false;
-		}
-	}
-
-	/**
-	 * 閲婃斁閿�(缁熶竴閲婃斁)
-	 */
-	public void unLock(String key) {
-		Integer lockType = threadLocal.get();
-		RLock lock = getLock(key, lockType);
-		lock.unlock();
-		threadLocal.remove();
-	}
-}

--
Gitblit v1.9.3