Idempotent.java 573 B

123456789101112131415161718192021222324252627
  1. package com.caimei.annotation;
  2. import java.lang.annotation.*;
  3. /**
  4. * 自定义幂等注解
  5. *
  6. * @author : Charles
  7. * @date : 2021/2/26
  8. */
  9. @Target(ElementType.METHOD)
  10. @Retention(RetentionPolicy.RUNTIME)
  11. @Documented
  12. public @interface Idempotent {
  13. /**
  14. * 前缀属性,作为redis缓存Key的一部分。
  15. */
  16. String prefix() default "idempotent_";
  17. /**
  18. * 需要的参数名数组
  19. */
  20. String[] keys();
  21. /**
  22. * 幂等过期时间(秒),即:在此时间段内,对API进行幂等处理。
  23. */
  24. int expire() default 3;
  25. }