Redisson's RRateLimiter distributed current limiting

1. Description

The article " Redis Lua + Token Bucket Algorithm to Implement Distributed Current Limiting" is introduced. I implement distributed current limiting through Lua script. If it is integrated Jedis, etc., you can use the method in this article to implement it yourself.
In redisson, there is already a ready-made RRateLimiter distributed current limiter. Here is an introduction to how to use this class.

2. Code implementation

The underlying trySetRate method is also implemented by Lua script. You can understand the logic of self-implemented distributed current limiting through the above article, and the principle of RRateLimiter will be very clear.

@Component
public class RRateLimiterService {
   
    
    

    private volatile RRateLimiter rRateLimiter

Guess you like

Origin blog.csdn.net/xunmengyou1990/article/details/128066908