Redis02 SpringBoot整合Redis

使用方式

1.创建boot项目引入Web(Spring Web)NoSQl(Spring Data Redis(Access+Driver))

2.修改配置文件

复制代码
spring:
    redis:
        host: 127.0.0.1
        port: 6379
        password: 123456
        lettuce:
            pool:
                max-active: 8 #最大连接
                max-idle: 8 #最大空闲连接
                min-idle: 0 #最小空闲连接
                max-wait: 1000ms #连接等待时间

3.编写测试类

复制代码
@SpringBootTest
class SpringbootRedisApplicationTests {
    <!-- @Autowired
    private RedisTemplate redisTemplate; -->
    @Autowired
    StringRedisTemplate stringRedisTemplate;//防止乱码
    //存值StringRedisTemplate相当于RedisTemplate<String, String>
    //设置当前的key以及value值
    @Test
    void testSet() {
        redisTemplate.opsForValue().set(key, value)
    }
}
相关推荐
cong_11 小时前
🐟 我把摸鱼岛重写了!现在群聊还能装进一张表格
前端·后端·github
wno70411 小时前
Centos下PostgreSQL安装部署详细步骤
java·数据库·spring boot
nice_lcj52012 小时前
【从零理解计算机网络 · 04】TCP 三次握手:为什么恰好是三次
java·后端·tcp/ip·计算机网络·面试·tcp·三次握手
JaguarJack12 小时前
NGINX 两处漏洞可导致未经身份验证的远程代码执行(CVE-2026-123633 和 CVE-2026-123007)
后端·nginx·nginx2root
BingoGo12 小时前
NGINX 两处漏洞可导致未经身份验证的远程代码执行(CVE-2026-123633 和 CVE-2026-123007)
后端·nginx
IT规划师12 小时前
Redis 核心机制 | Lazy Free:异步删除大 Key ,架构师视角的机制、代价与决策框架
redis·.net10·大key
码事漫谈1 天前
以后人人都可以成为导演
后端
Resean02231 天前
Spring 源码分析(二)配置类的解析与扫描
java·后端·spring