RedisLockUtil加锁解锁方法名修复sonar.LocksNotUnlockedCheck

This commit is contained in:
gaoqr
2025-05-22 09:32:00 +08:00
parent e0bfeb6567
commit 2f78e41313
9 changed files with 23 additions and 23 deletions
@@ -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);