声明:本站文章均为作者个人原创,图片均为实际截图。如有需要请收藏网站,禁止转载,谢谢配合!!!

java/springboot使用redis

1、安装springboot-redis依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

2、配置redis连接

spring:
    redis:
        database: 0
        host: localhost
        port: 6379
        jedis:
          pool:
            max-active: 1000
            max-wait: -1ms
            max-idle: 16
            min-idle: 8

3、使用redis

//set
redisTemplate.opsForValue().set(key, value, expire, TimeUnit.DAYS);
//删除
redisTemplate.delete(token)