Redis+Lua脚本+SpringAOP实现接口限流

提到限流,常规情况,可以通过spring-cloud-starter-alibaba-sentinel 或者 resilience4j-ratelimiter 组件完成,但是如果不借助现有组件让我们自己开发一套限流工作应该如何应对呢?
本次我们通过Redis + Lua 脚本来实现一个限流组件。
首先创建项目:redis-limit

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.wheelmouse</groupId>
        <artifactId>study</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>redis-limit</artifactId>
    <description>redis限流</description>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- 去掉springboot默认配置 -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--commons-api-util-->
        <dependency>
            <groupId>com.wheelmouse</groupId>
            <artifactId>commons-api-util</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!--使用log4j2替换 LogBack-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
        <!--guava-->
        <dependency>
            <groupId>

相关推荐

  1. Redis+Lua脚本+SpringAOP实现接口

    2024-03-23 05:12:07       43 阅读
  2. Resilience4j 实现接口

    2024-03-23 05:12:07       26 阅读
  3. SpringBoot整合resilience4j实现接口

    2024-03-23 05:12:07       61 阅读
  4. SpringBoot + Redis 实现接口,一个注解的事

    2024-03-23 05:12:07       35 阅读
  5. Redis实现

    2024-03-23 05:12:07       58 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-23 05:12:07       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-23 05:12:07       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-23 05:12:07       87 阅读
  4. Python语言-面向对象

    2024-03-23 05:12:07       96 阅读

热门阅读

  1. 从汉字之源厘清易混淆的倍数问题

    2024-03-23 05:12:07       41 阅读
  2. C# 多态 weijiejue

    2024-03-23 05:12:07       39 阅读
  3. 使用conda管理python环境

    2024-03-23 05:12:07       35 阅读
  4. Spark面试整理-如何创建RDD

    2024-03-23 05:12:07       46 阅读
  5. 使用conda创建python 虚拟环境

    2024-03-23 05:12:07       39 阅读
  6. RUST:Arc (Atomic Reference Counted) 原子引用计数

    2024-03-23 05:12:07       41 阅读
  7. Rust 语言的 HashMap

    2024-03-23 05:12:07       42 阅读
  8. Docker

    Docker

    2024-03-23 05:12:07      40 阅读
  9. RUST: let task = &mut task.unwrap().clone();

    2024-03-23 05:12:07       46 阅读
  10. jupyter | jupyter使用conda虚拟环境

    2024-03-23 05:12:07       42 阅读
  11. docker常用命令(不断更新)

    2024-03-23 05:12:07       38 阅读
  12. c语言教务成绩管理系统1000+

    2024-03-23 05:12:07       41 阅读
  13. mac 同步安卓手机屏幕

    2024-03-23 05:12:07       41 阅读
  14. 58.最后一个单词的长度

    2024-03-23 05:12:07       39 阅读
  15. 【力扣】387. 字符串中的第一个唯一字符

    2024-03-23 05:12:07       44 阅读