2021
11-17
11-17
Springboot+Redis实现API接口限流的示例代码
添加Redis的jar包.<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>在application.yml中配置redisspring:##Redisredis:database:0host:127.0.0.1port:6379password:jedis:pool:max-active:8max-wait:-1msmax-idle:8min-idle:0timeout:...
继续阅读 >
前言该篇介绍的内容如题,就是利用redis实现接口的限流( 某时间范围内最大的访问次数) 。正文 惯例,先看下我们的实战目录结构:首先是pom.xml核心依赖:<!--用于redis数据库连接--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><!--用于redislettuce连接池poo...