-
新增依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> 複製程式碼
-
application.properties
spring.redis.cluster.nodes=192.168.1.89:7003,192.168.1.89:7005,192.168.1.89:7002,192.168.1.89:7001,192.168.1.89:7004,192.168.1.89:7000 spring.redis.pool.max-idle=8 spring.redis.pool.min-idle=0 spring.redis.pool.max-active=8 spring.redis.pool.max-wait=-1
-
controller
@Controller public class UserController { @Autowired private StringRedisTemplate template; @Autowired private UserMapper userMapper; @RequestMapping("/users/{id}") @ResponseBody public User get(@PathVariable Long id){ User user = userMapper.get(id); ValueOperations<String, String> ops = this.template.opsForValue(); String key = "user_"+id; if (!this.template.hasKey(key)) { ops.set(key,user.getUsername()); } return user; } } 複製程式碼
spring boot redis做叢集
相關文章
- Spring Boot整合Redis叢集(Cluster模式)Spring BootRedis模式
- Spring Boot(十三):整合Redis哨兵,叢集模式實踐Spring BootRedis模式
- Spring Boot Redis 叢集效能最佳化(基於 Redisson)Spring BootRedis
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- spring boot redis做mybatis二級快取Spring BootRedisMyBatis快取
- redis 叢集Redis
- redis叢集Redis
- java程式碼中操作Redis:單機redis、叢集redis(spring+redis整合)JavaRedisSpring
- Redis cluster 叢集Redis
- redis叢集搭建Redis
- redis系列:叢集Redis
- 搭建 Redis 叢集Redis
- Redis Cluster(叢集)Redis
- Redis 叢集方法Redis
- Redis叢集方案Redis
- Redis 叢集方案Redis
- Redis-叢集Redis
- redis叢集原理Redis
- redis偽叢集配置Cluster叢集模式Redis模式
- Redis叢集 - cluster叢集、資料分片Redis
- spring-boot-route(十二)整合redis做為快取SpringbootRedis快取
- Spring Boot系列22 Spring Websocket實現websocket叢集方案的DemoSpring BootWeb
- Spring Boot系列21 Spring Websocket實現websocket叢集方案討論Spring BootWeb
- 認識Redis叢集——Redis ClusterRedis
- Spring Boot整合RedisSpring BootRedis
- Spring Boot 整合redisSpring BootRedis
- Redis(5.0) 叢集搭建Redis
- redis叢集的搭建Redis
- 搭建Redis原生叢集Redis
- docker-redis叢集DockerRedis
- Redis--叢集搭建Redis
- Docker搭建Redis叢集DockerRedis
- redis 叢集構建Redis
- redis叢集指導Redis
- 安裝 REDIS 叢集Redis
- redis叢集報錯Redis
- 搭建redis cluster叢集Redis
- Spring Boot(三):Spring Boot 中 Redis 的使用Spring BootRedis