com.biz.web.interceptor.accessLimit.DefaultAccessLimitCatch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biz-all Show documentation
Show all versions of biz-all Show documentation
BizX 是一个灵活而高效的业务开发框架, 其中也有很多为业务开发所需要的工具类的提供。
The newest version!
package com.biz.web.interceptor.accessLimit;
import com.biz.cache.map.SingletonScheduledMap;
import lombok.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 默认接口访问次数缓存
*
* @author francis
* @since 1.0.1
**/
public class DefaultAccessLimitCatch extends AbstractAccessLimitCatch {
/**
* 缓存10秒
*/
private final SingletonScheduledMap accessLimitCatchMap = SingletonScheduledMap.builder()
.died(1000 * 10L)
.build();
@Override
protected AtomicInteger get(String addr, String requestUrl) {
return accessLimitCatchMap.get(createInvokeKey(addr, requestUrl));
}
private static InvokeKey createInvokeKey(String addr, String requestUrl) {
return InvokeKey.builder()
.addr(addr)
.requestUrl(requestUrl)
.build();
}
@Setter
@Getter
@ToString
@EqualsAndHashCode
@Builder
private static class InvokeKey {
private String addr;
private String requestUrl;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy