|
@@ -3,7 +3,9 @@ package com.qmth.demo.api.controller;
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.boot.tools.models.KV;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -19,8 +21,8 @@ import java.util.Map;
|
|
|
@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
|
|
|
public class RedisController {
|
|
|
|
|
|
- // @Resource
|
|
|
- // private RedisTemplate<String, Object> redisTemplate;
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
@Resource
|
|
|
private RedissonClient redissonClient;
|
|
@@ -31,12 +33,24 @@ public class RedisController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/put")
|
|
|
- public Object put(@RequestParam String key, @RequestParam String value) {
|
|
|
+ public Object put(@RequestParam String key, @RequestParam Integer value) {
|
|
|
//redisTemplate.opsForValue().set(key, value);
|
|
|
redissonClient.getBucket(key).set(value);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/rget")
|
|
|
+ public Object rget(@RequestParam String key) {
|
|
|
+ return redisTemplate.opsForValue().get(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/rput")
|
|
|
+ public Object rput(@RequestParam String key, @RequestParam Integer value) {
|
|
|
+ redisTemplate.opsForValue().set(key, value);
|
|
|
+ //redissonClient.getBucket(key).set(KV.of(key, value));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping("/hget")
|
|
|
public Object hget(@RequestParam String[] key, @RequestParam String hashKey) {
|
|
|
//return redisTemplate.opsForHash().multiGet(hashKey, Arrays.asList(key));
|
|
@@ -47,7 +61,7 @@ public class RedisController {
|
|
|
public Object hput(@RequestParam String hashKey, @RequestParam String[] key, @RequestParam String[] value) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
for (int i = 0; i < key.length; i++) {
|
|
|
- map.put(key[i], value[i]);
|
|
|
+ map.put(key[i], KV.of(key[i], value[i]));
|
|
|
}
|
|
|
// redisTemplate.opsForHash().putAll(hashKey, map);
|
|
|
redissonClient.getMap(hashKey).putAll(map);
|