RateLimiter.java 695 B

123456789101112131415161718192021222324252627282930313233343536
  1. package cn.com.ayaojies.common.annotation;
  2. import cn.com.ayaojies.common.constant.CacheConstants;
  3. import cn.com.ayaojies.common.enums.LimitType;
  4. import java.lang.annotation.*;
  5. /**
  6. * 限流注解
  7. *
  8. * @author AyaoJies
  9. */
  10. @Target(ElementType.METHOD)
  11. @Retention(RetentionPolicy.RUNTIME)
  12. @Documented
  13. public @interface RateLimiter {
  14. /**
  15. * 限流key
  16. */
  17. public String key() default CacheConstants.RATE_LIMIT_KEY;
  18. /**
  19. * 限流时间,单位秒
  20. */
  21. public int time() default 60;
  22. /**
  23. * 限流次数
  24. */
  25. public int count() default 100;
  26. /**
  27. * 限流类型
  28. */
  29. public LimitType limitType() default LimitType.DEFAULT;
  30. }