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);
    }
}