Xiajijian
2025-10-13 a67c0844ecd1838e3130502f0c2ea0f0d8825cc5
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
package com.ard.work.domain.cache;
 
import java.util.concurrent.ConcurrentHashMap;
 
/**
 * 六合tcp服务器缓存
 *
 * @author liusuyi
 * @date 2024年11月01日13:53
 **/
public class TyTcpServerCache {
    // 使用 ConcurrentHashMap 来缓存TCP服务连接状态,key 是 ip:port(服务器地址) value 是连接状态
    private static final ConcurrentHashMap<String, Boolean> tcpServerCache = new ConcurrentHashMap<>();
 
    // 存储TCP服务连接状态到缓存
    public static void putTcpServerCache(String tcpServer,Boolean state) {
        tcpServerCache.put(tcpServer, state);
    }
 
    // 从缓存中获取TCP服务连接状态
    public static Boolean getTcpServerCache(String tcpServer) {
        return tcpServerCache.getOrDefault(tcpServer,false);
    }
 
    // 删除缓存中的TCP服务连接状态
    public static void removeTcpServerCache(String tcpServer) {
        tcpServerCache.remove(tcpServer);
    }
}