疯狂的狮子li
2021-06-16 c3636f1527cfc0041a7b54396da7f4ff2dd71e4f
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.core.redis.RedisLockManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -52,7 +53,7 @@
         if (flag) {
            log.info("获取锁成功: " + key);
            Thread.sleep(3000);
            redisLockManager.unLock();
            redisLockManager.unLock(key);
            log.info("释放锁成功: " + key);
         } else {
            log.error("获取锁失败: " + key);
@@ -62,4 +63,13 @@
      }
      return AjaxResult.success();
   }
   /**
    * 测试spring-cache注解
    */
   @Cacheable(value = "test", key = "#key")
   @GetMapping("/testCache")
   public AjaxResult<String> testCache(String key) {
      return AjaxResult.success("操作成功", key);
   }
}