ny
昨天 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package jnpf.util;
 
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
 
/**
 * 网关工具类
 */
public class GatewayUtil {
 
    private static TimedCache<String, Integer> renewLimit = null;
    private static final long TIMEOUT = 1000L * 60;
 
    static {
        renewLimit = CacheUtil.newTimedCache(TIMEOUT);
        // 一分钟清理一次无用数据
        renewLimit.schedulePrune(TIMEOUT);
    }
 
    /**
     * 同一个TOKEN一分钟内只会续期一次
     */
    public static void renewToken(String token){
        if(renewLimit.containsKey(token)) {
            return;
        }
        UserProvider.renewTimeout(token);
        renewLimit.put(token, 0);
    }
 
}