| | |
| | | package com.ard.work.domain.cache; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * 天宇tcp服务器缓存 |
| | | * 六合tcp服务器缓存 |
| | | * |
| | | * @author liusuyi |
| | | * @date 2024年11月01日13:53 |
| | |
| | | private static final ConcurrentHashMap<String, Boolean> tcpServerCache = new ConcurrentHashMap<>(); |
| | | |
| | | // 存储TCP服务连接状态到缓存 |
| | | public static void putTcpServerCache(String tcpServer,Boolean state) { |
| | | tcpServerCache.put(tcpServer, state); |
| | | public static void putTcpServerCache(String serverId,Boolean state) { |
| | | tcpServerCache.put(serverId, state); |
| | | } |
| | | |
| | | // 从缓存中获取TCP服务连接状态 |
| | | public static Boolean getTcpServerCache(String tcpServer) { |
| | | return tcpServerCache.getOrDefault(tcpServer,false); |
| | | public static Boolean getTcpServerCache(String serverId) { |
| | | return tcpServerCache.getOrDefault(serverId,false); |
| | | } |
| | | |
| | | // 删除缓存中的TCP服务连接状态 |
| | | public static void removeTcpServerCache(String tcpServer) { |
| | | tcpServerCache.remove(tcpServer); |
| | | public static void removeTcpServerCache(String serverId) { |
| | | tcpServerCache.remove(serverId); |
| | | } |
| | | |
| | | public static Map<String, Boolean> getTcpServerCacheMap() { |
| | | return new HashMap<>(tcpServerCache); // 返回一个副本,避免外部修改原始缓存 |
| | | } |
| | | |
| | | } |