package com.itheima.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*****
 * @Author: http://www.itheima.com
 * @Description: com.itheima.controller.RedisController
 ****/
@RestController
@RequestMapping(value = "/redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;

    /***
     * 操作Redis
     * @return
     */
    @GetMapping(value = "/handler")
    public String handler(){
        //添加数据
        redisTemplate.boundValueOps("itheima").set("www.itheima.com");
        //获取数据
        return redisTemplate.boundValueOps("itheima").get().toString();
    }
}
