sxq
2021-06-22 645c926bbd52baa90c0a4af0d253047709c5e02c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.ruoyi.demo.controller;
 
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisLockManager;
import com.ruoyi.demo.service.ITestDemoService;
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;
 
 
/**
 * 测试分布式锁的样例
 *
 * @author shenxinquan
 */
@Slf4j
@RestController
@RequestMapping("/demo/redisLock")
public class RedisLockController {
 
    @Autowired
    private ITestDemoService testDemoService;
 
    /**
     * 测试lock4j
     * @param key
     * @param value
     * @return
     */
    @GetMapping("/testLock4j")
    public  AjaxResult<String> testLock4j(String key,String value){
        testDemoService.testLock4j(key);
        return AjaxResult.success("操作成功",value);
    }
    @GetMapping("/testLock4jLockTemaplate")
    public  AjaxResult<String> testLock4jLockTemaplate(String key,String value){
        testDemoService.testLock4jLockTemaplate(key);
        return AjaxResult.success("操作成功",value);
    }
 
 
 
 
    /**
     * 测试spring-cache注解
     */
    @Cacheable(value = "test", key = "#key")
    @GetMapping("/testCache")
    public AjaxResult<String> testCache(String key) {
        return AjaxResult.success("操作成功", key);
    }
}