mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
RedisLockUtil加锁解锁方法名修复sonar.LocksNotUnlockedCheck
This commit is contained in:
+5
-5
@@ -32,7 +32,7 @@ public class RedisLockUtil {
|
||||
* @param key rediskey
|
||||
* @return true拿到锁,反之没有做对应的业务提醒
|
||||
*/
|
||||
public boolean lock(String key) {
|
||||
public boolean acquireLock(String key) {
|
||||
boolean getLock = false;
|
||||
try {
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
@@ -51,7 +51,7 @@ public class RedisLockUtil {
|
||||
* @param waitTime 等待获取锁的时间,传空则按照默认配置
|
||||
* @return true拿到锁,反之没有做对应的业务提醒
|
||||
*/
|
||||
public boolean lock(String key, Integer waitTime, Integer timeout) {
|
||||
public boolean acquireLock(String key, Integer waitTime, Integer timeout) {
|
||||
boolean getLock = false;
|
||||
try {
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
@@ -70,7 +70,7 @@ public class RedisLockUtil {
|
||||
*
|
||||
* @param key rediskey
|
||||
*/
|
||||
public void unlock(String key) {
|
||||
public void releaseLock(String key) {
|
||||
try {
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
lock.unlock();
|
||||
@@ -88,7 +88,7 @@ public class RedisLockUtil {
|
||||
* @param timeout
|
||||
* @return
|
||||
*/
|
||||
public boolean lock(String key, String uniqeKey, Integer timeout) {
|
||||
public boolean acquireLock(String key, String uniqeKey, Integer timeout) {
|
||||
return redisTemplate.opsForValue().setIfAbsent(key, uniqeKey, timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class RedisLockUtil {
|
||||
* @param key
|
||||
* @param uniqeKey 解锁时校验,避免同key下其他任务解锁到
|
||||
*/
|
||||
public void unlock(String key, String uniqeKey) {
|
||||
public void releaseLock(String key, String uniqeKey) {
|
||||
Object object = redisTemplate.opsForValue().get(key);
|
||||
if (ObjectUtil.equal(object, uniqeKey)) {
|
||||
Boolean delete = redisTemplate.delete(key);
|
||||
|
||||
Reference in New Issue
Block a user