@@ -14,12 +14,12 @@ public class WxMsgIdInMemoryDuplicateChecker implements WxMsgIdDuplicateChecker
1414 /**
1515 * 一个消息ID在内存的过期时间:15秒
1616 */
17- private final Long TIME_TO_LIVE ;
17+ private final Long timeToLive ;
1818
1919 /**
2020 * 每隔多少周期检查消息ID是否过期:5秒
2121 */
22- private final Long CLEAR_PERIOD ;
22+ private final Long clearPeriod ;
2323
2424 private final ConcurrentHashMap <Long , Long > msgId2Timestamp = new ConcurrentHashMap <Long , Long >();
2525
@@ -31,8 +31,8 @@ public class WxMsgIdInMemoryDuplicateChecker implements WxMsgIdDuplicateChecker
3131 * </pre>
3232 */
3333 public WxMsgIdInMemoryDuplicateChecker () {
34- this .TIME_TO_LIVE = 15 * 1000l ;
35- this .CLEAR_PERIOD = 5 * 1000l ;
34+ this .timeToLive = 15 * 1000l ;
35+ this .clearPeriod = 5 * 1000l ;
3636 this .start ();
3737 }
3838
@@ -42,8 +42,8 @@ public WxMsgIdInMemoryDuplicateChecker() {
4242 * @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒
4343 */
4444 public WxMsgIdInMemoryDuplicateChecker (Long timeToLive , Long clearPeriod ) {
45- this .TIME_TO_LIVE = timeToLive ;
46- this .CLEAR_PERIOD = clearPeriod ;
45+ this .timeToLive = timeToLive ;
46+ this .clearPeriod = clearPeriod ;
4747 this .start ();
4848 }
4949
@@ -53,10 +53,10 @@ private void start() {
5353 public void run () {
5454 try {
5555 while (true ) {
56- Thread .sleep (CLEAR_PERIOD );
56+ Thread .sleep (clearPeriod );
5757 Long now = System .currentTimeMillis ();
5858 for (Map .Entry <Long , Long > entry : msgId2Timestamp .entrySet ()) {
59- if (now - entry .getValue () > TIME_TO_LIVE ) {
59+ if (now - entry .getValue () > timeToLive ) {
6060 msgId2Timestamp .entrySet ().remove (entry );
6161 }
6262 }
0 commit comments