package cd.casic.plugin;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author：mianbin
 * @Package：cd.casic.plugin
 * @Project：ops
 * @name：PluginCache
 * @Date：2024/03/18 9:34
 * @Filename：PluginCache
 * @description：已安装插件的存储
 */
public class PluginCache {
    private static final Map<String, PluginInfo> pluginMaps = Collections.synchronizedMap(new HashMap<>());

    public static void put(String pluginId, PluginInfo plugin) {
        pluginMaps.putIfAbsent(pluginId, plugin);
    }

    public static PluginInfo getPlugin(String pluginId) {
        return pluginMaps.get(pluginId);
    }

    public static void remove(String pluginId) {
        pluginMaps.remove(pluginId);
    }

    public static Map<String, PluginInfo> getAllPlugin() {
        return pluginMaps;
    }

    public static Boolean isExist(String pluginId) {
        return pluginMaps.containsKey(pluginId);
    }
}
