Class LockController

java.lang.Object
cn.sliew.carp.example.redisson.controller.LockController

@RestController @RequestMapping("/api/carp/example/redisson/lock") public class LockController extends Object
  • Constructor Details

    • LockController

      public LockController()
  • Method Details

    • lockAndUnlock

      @PostMapping("/lock-unlock") public String lockAndUnlock() throws Exception
      测试自动续期,自动续期有 1 个要点: 1.不设置锁ttl,所以会无限续期下去。如果显式指定,则不会生效。
      Throws:
      Exception
    • lockAndUnlockAsync

      @PostMapping("/lock-unlock-async") public String lockAndUnlockAsync() throws Exception
      测试异步释放锁 1.默认是只有持有锁的线程才可以释放锁,异步情况下,必须强制释放锁才可以
      Throws:
      Exception
    • lock

      @PostMapping("/lock") public String lock() throws Exception
      Throws:
      Exception
    • unlock

      @PostMapping("/unlock") public void unlock(@RequestParam("key") String key) throws Exception
      Throws:
      Exception
    • forceUnlock

      @PostMapping("/forceUnlock") public void forceUnlock(@RequestParam("key") String key) throws Exception
      Throws:
      Exception
    • scheduleLambda

      @GetMapping("/lock-ttl") public String scheduleLambda(@RequestParam("key") String key) throws Exception
      Throws:
      Exception