疯狂的狮子li
2022-01-29 53da7140c2683e4d80c0b2536b7972d9c516729a
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
@@ -1,6 +1,6 @@
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.redis.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -44,8 +44,8 @@
    @ApiOperation("测试 @Cacheable")
    @Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
    @GetMapping("/test1")
    public AjaxResult<String> test1(String key, String value) {
        return AjaxResult.success("操作成功", value);
    public R<String> test1(String key, String value) {
        return R.ok("操作成功", value);
    }
    /**
@@ -59,8 +59,8 @@
    @ApiOperation("测试 @CachePut")
    @CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
    @GetMapping("/test2")
    public AjaxResult<String> test2(String key, String value) {
        return AjaxResult.success("操作成功", value);
    public R<String> test2(String key, String value) {
        return R.ok("操作成功", value);
    }
    /**
@@ -74,8 +74,8 @@
    @ApiOperation("测试 @CacheEvict")
    @CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
    @GetMapping("/test3")
    public AjaxResult<String> test3(String key, String value) {
        return AjaxResult.success("操作成功", value);
    public R<String> test3(String key, String value) {
        return R.ok("操作成功", value);
    }
    /**
@@ -85,7 +85,7 @@
     */
    @ApiOperation("测试设置过期时间")
    @GetMapping("/test6")
    public AjaxResult<Boolean> test6(String key, String value) {
    public R<Boolean> test6(String key, String value) {
        RedisUtils.setCacheObject(key, value);
        boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
        System.out.println("***********" + flag);
@@ -95,7 +95,7 @@
            e.printStackTrace();
        }
        Object obj = RedisUtils.getCacheObject(key);
        return AjaxResult.success("操作成功", value.equals(obj));
        return R.ok(value.equals(obj));
    }
}