初次提交代码
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package com.common.controller;
|
||||
import com.common.entity.DeviceDevice;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/cache")
|
||||
public class CacheController {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@GetMapping("/key/{key}")
|
||||
public DeviceDevice getCacheValue(@PathVariable String key) {
|
||||
|
||||
// 这里先尝试作为字符串键获取
|
||||
System.out.println("key:" +key);
|
||||
//System.out.println(redisTemplate.opsForHash().entries(key).toString());
|
||||
return (DeviceDevice) redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user