Redis:高效的缓存处理
Redis作为现在最流行的缓存技术,把接收到的数据,转换为硬盘数据或者数据库,存储在缓存中,减少多重数据同时的压力,
也可以实现单点,主要作为缓存
1.先分享一些配置pom.xml
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency>
2.再看一下redis的配置
#### Redis
com.oneinlet.config.redisConfig.maxTotal=
30
com.oneinlet.config.redisConfig.maxIdle=
10
com.oneinlet.config.redisConfig.maxWaitMillis=
51000
com.oneinlet.config.redisConfig.minIdle=
5
com.oneinlet.config.redisConfig.port=
6379
com.oneinlet.config.redisConfig.hostName=
localhost
com.oneinlet.config.redisConfig.password=
123456
com.oneinlet.config.redisConfig.timeout=
15000
3.controller的方法
@RequestMapping(
"/putValueToRedis/{name}")
public Object getRedis(
@PathVariable String name) {
redisService.setKeyValue(name,
"www.520code.net");
return setOKResult(); }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通