SpringBoot使用redis

作者: gu_lao_rou-p 分类: 未分类 发布时间: 2023-01-15 20:51
<!--redis-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <version>1.4.0.RELEASE</version>
        </dependency>

引入redis依赖,注意版本,有可能会出现版本不匹配的情况

spring.redis.database=0
spring.redis.host=192.168.1.137
spring.redis.port=6379
spring.redis.password=r123456
spring.redis.jedis.pool.max-active=1000
spring.redis.jedis.pool.max-wait=-1ms
spring.redis.jedis.pool.max-idle=16
spring.redis.jedis.pool.min-idle=8

配置文件

@Resource
private RedisTemplate redisTemplate;

controller文件内添加

redisTemplate.opsForValue().set(token, userId+"", 3600 * 24, TimeUnit.SECONDS);

往redis内存入数据


Warning: Undefined variable $aria_req in /www/wwwroot/l.lvovl.cn/wp-content/themes/JieStyle-Two-master/comments.php on line 26

Warning: Undefined variable $aria_req in /www/wwwroot/l.lvovl.cn/wp-content/themes/JieStyle-Two-master/comments.php on line 27

Warning: Undefined variable $aria_req in /www/wwwroot/l.lvovl.cn/wp-content/themes/JieStyle-Two-master/comments.php on line 28
标签云