Home > Database > Redis > How to integrate SpringBoot with Redis

How to integrate SpringBoot with Redis

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-05-26 22:31:30
forward
739 people have browsed it

1. Introduce dependencies

How to integrate SpringBoot with Redis

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId><version>2.4.4</version></dependency>
Copy after login

2. Backend code:

spring.redis.database=0
spring.redis.host=192.168.1.xxx
spring.redis.port=8099
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-wait=-1ms
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0
spring.redis.timeout=0
Copy after login
@Controller
@Api(tags = "书本数据接口")
@EnableCaching//开启缓存public class BookController {

}
Copy after login
  @Cacheable(value = "book_id")//使用缓存    @Overridepublic Book getBookById(Integer id) {
        System.out.println("从数据库中查询。。。。。");return bookMapper.getBookById(id);
    }
Copy after login

The above is the detailed content of How to integrate SpringBoot with Redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php redis connection problem
From 1970-01-01 08:00:00
0
0
0
About a small error in the redis manual
From 1970-01-01 08:00:00
0
0
0
python2.7 - django cannot connect to redis
From 1970-01-01 08:00:00
0
0
0
I can't connect to redis using php
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template