Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
7edc80c6
Commit
7edc80c6
authored
Mar 24, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
不记录系统日志
parent
b2443702
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
4 deletions
+124
-4
pom.xml
yzg-util-redis/pom.xml
+4
-4
TestCache.java.bak
yzg-util-redis/src/test/java/TestCache.java.bak
+35
-0
TestController.java.bak
yzg-util-redis/src/test/java/TestController.java.bak
+85
-0
No files found.
yzg-util-redis/pom.xml
View file @
7edc80c6
...
@@ -13,10 +13,10 @@
...
@@ -13,10 +13,10 @@
<dependencies>
<dependencies>
<!-- 添加springboot对redis的支持 -->
<!-- 添加springboot对redis的支持 -->
<
dependency
>
<
!--<dependency>--
>
<
groupId>
org.springframework.boot
</groupId
>
<
!--<groupId>org.springframework.boot</groupId>--
>
<
artifactId>
spring-boot-starter-data-redis
</artifactId
>
<
!--<artifactId>spring-boot-starter-data-redis</artifactId>--
>
<
/dependency
>
<
!--</dependency>--
>
<dependency>
<dependency>
<groupId>
com.alicp.jetcache
</groupId>
<groupId>
com.alicp.jetcache
</groupId>
<artifactId>
jetcache-starter-redis-lettuce
</artifactId>
<artifactId>
jetcache-starter-redis-lettuce
</artifactId>
...
...
yzg-util-redis/src/test/java/TestCache.java.bak
0 → 100644
View file @
7edc80c6
import com.alicp.jetcache.anno.CacheInvalidate;
import com.alicp.jetcache.anno.CacheUpdate;
import com.alicp.jetcache.anno.Cached;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.stereotype.Component;
@Component
public class TestCache {
@Cached(name = "test.", cacheNullValue = true)
public SecurityProperties.User load(SecurityProperties.User tokenVo) {
return tokenVo;
}
/**
* 保存接口请求日志
*
* @param tokenVo
*/
@CacheUpdate(name = "test.", key = "args[0].token", value = "#tokenVo")
public String save(SecurityProperties.User tokenVo) {
return tokenVo.getName();
}
/**
* 保存接口请求日志
*
* @param tokenVo 请求数据
* @retur 保存主键
*/
@CacheInvalidate(name = "test.", key = "args[0].token")
public int remove(SecurityProperties.User tokenVo) {
return 0;
}
}
yzg-util-redis/src/test/java/TestController.java.bak
0 → 100644
View file @
7edc80c6
import com.tourbida.login.vo.TokenVo;
import com.yanzuoguang.util.vo.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 颜佐光
*
* @author huangzheng
*/
@RestController
@RequestMapping("/redis")
@Api(value = "测试redis", description = "测试redis")
public class TestController {
@Resource
private RedisTemplate redisTemplate;
@Autowired
private TestCache testCache;
@GetMapping("/setUser")
public String setUser() {
SecurityProperties.User user = new SecurityProperties.User();
user.setName("yanzuoguang");
user.setPassword("123456");
List<String> list = new ArrayList<>();
list.add("小学");
list.add("初中");
list.add("高中");
list.add("大学");
user.setRoles(list);
redisTemplate.opsForValue().set("test.userInfo", user);
return "success";
}
@GetMapping("/getUser")
public SecurityProperties.User getUser() {
return (SecurityProperties.User) redisTemplate.opsForValue().get("test.userInfo");
}
/**
* 测试加载
*
* @return
*/
@PostMapping(value = "/load", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "测试加载", notes = "测试加载")
public ResponseResult<TokenVo> load(@RequestBody TokenVo req) {
return ResponseResult.result(testCache.load(req));
}
/**
* 测试保存
*
* @return
*/
@PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "测试保存", notes = "测试保存")
public ResponseResult<String> save(@RequestBody TokenVo req) {
return ResponseResult.result(testCache.save(req));
}
/**
* 测试删除
*
* @return
*/
@PostMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "测试删除", notes = "测试删除")
public ResponseResult<Integer> remove(@RequestBody TokenVo req) {
return ResponseResult.result(testCache.remove(req));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment