zj
2024-06-03 3603ecb207f7e712c635f19531e05fac4d19e53f
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
32
33
34
35
package kernel.sessiontoken.internal;
 
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
 
import kernel.sessiontoken.SessionTokenService;
import kernel.util.StringUtils;
import kernel.util.UUIDGenerator;
 
public class SessionTokenServiceImpl implements SessionTokenService {
 
    private volatile Map<String, String> cache = new ConcurrentHashMap<String, String>();
 
    public String savePut(String partyId) {
        String session_token = UUIDGenerator.getUUID();
        cache.put(session_token, partyId);
        return session_token;
    }
 
    public String cacheGet(String session_token) {
        if (StringUtils.isNullOrEmpty(session_token)) {
            return null;
        }
        return cache.get(session_token);
    }
 
    @Override
    public void del(String session_token) {
        if (StringUtils.isNullOrEmpty(session_token)) {
            return;
        }
        cache.remove(session_token);
    }
 
}