-
新增依賴
<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模式
- redis叢集Redis
- redis 叢集Redis
- Spring Boot系列22 Spring Websocket實現websocket叢集方案的DemoSpring BootWeb
- Spring Boot系列21 Spring Websocket實現websocket叢集方案討論Spring BootWeb
- spring-boot-route(十二)整合redis做為快取SpringbootRedis快取
- redis叢集原理Redis
- redis叢集搭建Redis
- 搭建 Redis 叢集Redis
- Redis cluster 叢集Redis
- redis系列:叢集Redis
- Redis Cluster(叢集)Redis
- redis偽叢集配置Cluster叢集模式Redis模式
- Spring Boot整合RedisSpring BootRedis
- Spring Boot 整合redisSpring BootRedis
- Spring Boot Quartz 分散式叢集任務排程實現Spring Bootquartz分散式
- 認識Redis叢集——Redis ClusterRedis
- 【Redis】用python操作redis叢集RedisPython
- 搭建redis cluster叢集Redis
- redis 叢集構建Redis
- redis叢集報錯Redis
- redis 4.0.11 叢集搭建Redis
- Redis--叢集搭建Redis
- docker-redis叢集DockerRedis
- redis叢集的搭建Redis
- Docker搭建Redis叢集DockerRedis
- Redis(5.0) 叢集搭建Redis
- 搭建Redis原生叢集Redis
- redis叢集指導Redis
- Spring-Boot整合RedisSpringbootRedis
- Spring Boot-Redis教程Spring BootRedis
- spring boot(三)整合 redisSpring BootRedis
- spring boot中redis使用Spring BootRedis
- Jedis操作單節點redis,叢集及redisTemplate操作redis叢集(一)Redis
- 基於Dokcer搭建Redis叢集(主從叢集)Redis
- Spring Boot 2.x基礎教程:使用EhCache快取叢集Spring Boot快取