添加接口防抖

This commit is contained in:
韩鹏辉
2024-06-14 14:31:03 +08:00
parent ada1dafe86
commit f766e2508d

View File

@@ -5,10 +5,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Component
@@ -583,4 +580,15 @@ public class RedisUtils {
}
}
public boolean lock(String key, long timeout, TimeUnit timeUnit) {
String value = UUID.randomUUID().toString();
Boolean success = redisTemplate.opsForValue().setIfAbsent(key, value, timeout, timeUnit);
return success != null && success;
}
public void releaseLock(String key) {
redisTemplate.delete(key);
}
}