Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问源码中ip的规则中,哪里能看到会把当前的key设置到redis中。 #18

Open
jiazhanfeng opened this issue Sep 1, 2022 · 0 comments

Comments

@jiazhanfeng
Copy link

RAtomicLong rRequestCount = this.redissonClient.getAtomicLong("ratelimiter_request_count".concat(requestUrl).concat(ipAddress));
RAtomicLong rExpirationTime = this.redissonClient.getAtomicLong("ratelimiter_expirationtime".concat(requestUrl).concat(ipAddress));
if (!rExpirationTime.isExists()) {
rRequestCount.set(0L);
rExpirationTime.set(0L);
rExpirationTime.expire((long)expirationTime, TimeUnit.MILLISECONDS);
} else {
RMap rHitMap = this.redissonClient.getMap("ratelimiter_hit_crawlerstrategy");
if (rRequestCount.incrementAndGet() > (long)requestMaxSize || rHitMap.containsKey(ipAddress)) {
rExpirationTime.expire(10L, TimeUnit.DAYS);
rHitMap.put(ipAddress, requestUrl);
System.out.println("Intercepted request, uri: " + requestUrl + ", ip:" + ipAddress + " request " + requestMaxSize + " times in " + expirationTime + " ms");
return true;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant