package cn.itcast.redisdemo.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@Autowired
private StringRedisTemplate redisTemplate;
@GetMapping("/get/{key}")
public String hi(@PathVariable String key) {
return redisTemplate.opsForValue().get(key);
}
@GetMapping("/set/{key}/{value}")
public String hi(@PathVariable String key, @PathVariable String value) {
redisTemplate.opsForValue().set(key, value);
return "success";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Redis-demo的文件
共5个文件
java:3个
xml:1个
yaml:1个
0 下载量 144 浏览量
2024-03-24
23:27:05
上传
评论
收藏 4KB ZIP 举报
温馨提示
RedisTemplate
资源推荐
资源详情
资源评论
收起资源包目录
redis-demo.zip (5个子文件)
pom.xml 2KB
src
test
java
cn
itcast
redisdemo
RedisDemoApplicationTests.java 468B
main
resources
application.yaml 90B
java
cn
itcast
redisdemo
RedisDemoApplication.java 517B
web
HelloController.java 822B
共 5 条
- 1
资源评论
豆浆-plus
- 粉丝: 437
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功