diff --git a/beacon-cache/src/main/java/com/mashibing/cache/controller/TestController.java b/beacon-cache/src/main/java/com/mashibing/cache/controller/TestController.java new file mode 100644 index 0000000..47a1628 --- /dev/null +++ b/beacon-cache/src/main/java/com/mashibing/cache/controller/TestController.java @@ -0,0 +1,31 @@ +package com.mashibing.cache.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author zjw + * @description + */ +@RestController +public class TestController { + + @Autowired + private RedisTemplate redisTemplate; + + // 写测试 hash结构 + @PostMapping("/test/set/{key}") + public String set(@PathVariable String key, @RequestBody Map map){ + redisTemplate.opsForHash().putAll(key,map); + return "ok"; + } + // 读测试 + @GetMapping("/test/get/{key}") + public Map get(@PathVariable String key){ + Map result = redisTemplate.opsForHash().entries(key); + return result; + } +}