Administrator
5 天以前 aa33e56e37cd19b88ae8eea69c5ebc7c6da8b1d2
src/main/java/com/zy/core/cache/SlaveConnection.java
@@ -2,19 +2,19 @@
import com.zy.core.ThreadHandler;
import com.zy.core.enums.SlaveType;
import io.swagger.models.auth.In;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
 * 线程缓存容器
 * Created by vincent on 2020/8/4
 */
public class SlaveConnection {
    private static final String _LINK = "_";
    private static Map<String, ThreadHandler> conContain = new ConcurrentHashMap<>();
    private static final Map<String, ThreadHandler> conContain = new ConcurrentHashMap<>();
    public static void put(SlaveType type, Integer id, ThreadHandler threadHandler) {
        String key = toKey(type, id);
@@ -22,8 +22,8 @@
        conContain.put(key, threadHandler);
    }
    public static ThreadHandler get(SlaveType type, Integer key) {
        return conContain.get(toKey(type, key));
    public static ThreadHandler get(SlaveType type, Integer id) {
        return conContain.get(toKey(type, id));
    }
    public static void remove(SlaveType type, Integer id) {
@@ -40,7 +40,7 @@
            return null;
        }
        String key = null;
        for (Map.Entry<String, ThreadHandler> entry : conContain.entrySet()){
        for (Map.Entry<String, ThreadHandler> entry : conContain.entrySet()) {
            if (entry.getValue() == threadHandler) {
                key = entry.getKey();
                break;
@@ -56,8 +56,8 @@
        }
    }
    private static String toKey(SlaveType type, Integer id){
        return type.toString()+_LINK+id;
    private static String toKey(SlaveType type, Integer id) {
        return type.toString() + _LINK + id;
    }
}