StringRedisTemplate常用API
转载自网络:
//向redis里存入数据和设置缓存时间
stringRedisTemplate.opsForValue().set("test", "100",60*10,TimeUnit.SECONDS);
//val做-1操作
stringRedisTemplate.boundValueOps("test").increment(-1);
//根据key获取缓存中的val
stringRedisTemplate.opsForValue().get("test")
//val +1
stringRedisTemplate.boundValueOps("test").increment(1);
//根据key获取过期时间
stringRedisTemplate.getExpire("test")
//根据key获取过期时间并换算成指定单位
stringRedisTemplate.getExpire("test",TimeUnit.SECONDS)
//根据key删除缓存
stringRedisTemplate.delete("test");
//检查key是否存在,返回boolean值
stringRedisTemplate.hasKey("546545");
//向指定key中存放set集合
stringRedisTemplate.opsForSet().add("red_123", "1","2","3");
//设置过期时间
stringRedisTemplate.expire("red_123",1000 , TimeUnit.MILLISECONDS);
//根据key查看集合中是否存在指定数据
stringRedisTemplate.opsForSet().isMember("red_123", "1")
//根据key获取set集合
stringRedisTemplate.opsForSet().members("red_123");
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下