56 lines
1.4 KiB
Java
Raw Normal View History

2021-06-04 16:09:43 +08:00
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.AjaxResult;
2021-06-09 23:31:47 +08:00
import com.ruoyi.common.core.redis.RedisLockManager;
import com.ruoyi.demo.service.ITestDemoService;
2021-06-09 23:31:47 +08:00
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
2021-06-10 20:23:15 +08:00
import org.springframework.cache.annotation.Cacheable;
2021-06-04 16:09:43 +08:00
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试分布式锁的样例
*
* @author shenxinquan
*/
2021-06-09 23:31:47 +08:00
@Slf4j
2021-06-04 16:09:43 +08:00
@RestController
@RequestMapping("/demo/redisLock")
public class RedisLockController {
2021-06-09 23:31:47 +08:00
@Autowired
private ITestDemoService testDemoService;
2021-06-09 23:31:47 +08:00
2021-06-04 16:09:43 +08:00
/**
* 测试lock4j
* @param key
* @param value
* @return
2021-06-04 16:09:43 +08:00
*/
@GetMapping("/testLock4j")
public AjaxResult<String> testLock4j(String key,String value){
testDemoService.testLock4j(key);
2021-06-04 16:09:43 +08:00
return AjaxResult.success("操作成功",value);
}
@GetMapping("/testLock4jLockTemaplate")
public AjaxResult<String> testLock4jLockTemaplate(String key,String value){
testDemoService.testLock4jLockTemaplate(key);
return AjaxResult.success("操作成功",value);
2021-06-09 23:31:47 +08:00
}
2021-06-10 20:23:15 +08:00
2021-06-10 20:23:15 +08:00
/**
* 测试spring-cache注解
*/
@Cacheable(value = "test", key = "#key")
@GetMapping("/testCache")
public AjaxResult<String> testCache(String key) {
return AjaxResult.success("操作成功", key);
}
2021-06-04 16:09:43 +08:00
}