From cd0aad10b0e6fe284eafafd932b9d4705460c04f Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期日, 31 十月 2021 21:28:19 +0800
Subject: [PATCH] fix 修复 SysOss、SysOssConfig 未继承 BaseEntity 基础实体问题
---
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
index 4588f13..903b982 100644
--- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
@@ -1,6 +1,9 @@
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.RedisUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
@@ -10,6 +13,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.util.concurrent.TimeUnit;
+
/**
* spring-cache 婕旂ず妗堜緥
*
@@ -17,6 +22,7 @@
*/
// 绫荤骇鍒� 缂撳瓨缁熶竴閰嶇疆
//@CacheConfig(cacheNames = "redissonCacheMap")
+@Api(value = "spring-cache 婕旂ず妗堜緥", tags = {"spring-cache 婕旂ず妗堜緥"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/demo/cache")
@@ -31,8 +37,12 @@
* 濡傛灉娌℃湁,灏辫皟鐢ㄦ柟娉�,鐒跺悗鎶婄粨鏋滅紦瀛樿捣鏉�
* 杩欎釜娉ㄨВ銆屼竴鑸敤鍦ㄦ煡璇㈡柟娉曚笂銆�
*
+ * 閲嶇偣璇存槑: 缂撳瓨娉ㄨВ涓ヨ皑涓庡叾浠栫瓫閫夋暟鎹姛鑳戒竴璧蜂娇鐢�
+ * 渚嬪: 鏁版嵁鏉冮檺娉ㄨВ 浼氶�犳垚 缂撳瓨鍑荤┛ 涓� 鏁版嵁涓嶄竴鑷撮棶棰�
+ *
* cacheNames 涓洪厤缃枃浠跺唴 groupId
*/
+ @ApiOperation("娴嬭瘯 @Cacheable")
@Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test1")
public AjaxResult<String> test1(String key, String value){
@@ -47,6 +57,7 @@
*
* cacheNames 涓� 閰嶇疆鏂囦欢鍐� groupId
*/
+ @ApiOperation("娴嬭瘯 @CachePut")
@CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test2")
public AjaxResult<String> test2(String key, String value){
@@ -61,10 +72,31 @@
*
* cacheNames 涓� 閰嶇疆鏂囦欢鍐� groupId
*/
+ @ApiOperation("娴嬭瘯 @CacheEvict")
@CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test3")
public AjaxResult<String> test3(String key, String value){
return AjaxResult.success("鎿嶄綔鎴愬姛", value);
}
+ /**
+ * 娴嬭瘯璁剧疆杩囨湡鏃堕棿
+ * 鎵嬪姩璁剧疆杩囨湡鏃堕棿10绉�
+ * 11绉掑悗鑾峰彇 鍒ゆ柇鏄惁鐩哥瓑
+ */
+ @ApiOperation("娴嬭瘯璁剧疆杩囨湡鏃堕棿")
+ @GetMapping("/test6")
+ public AjaxResult<Boolean> test6(String key, String value){
+ RedisUtils.setCacheObject(key, value);
+ boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
+ System.out.println("***********" + flag);
+ try {
+ Thread.sleep(11 * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ Object obj = RedisUtils.getCacheObject(key);
+ return AjaxResult.success("鎿嶄綔鎴愬姛", value.equals(obj));
+ }
+
}
--
Gitblit v1.9.3