#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2023/4/9 0:02 # @Author : old tom # @File : connector_cache.py # @Project : futool-tiny-datahub # @Desc : class ConnectorCacheManage(object): """ 连接器缓存管理 todo 缓存可能会出现V被GC回收,但是K还存在的问题,需要加入轮询机制处理 """ # 缓存容器 CONNECTOR_CACHE = {} def exist(self, connector_id): return connector_id in self.CONNECTOR_CACHE.keys() def get(self, connector_id): return self.CONNECTOR_CACHE[connector_id] def set(self, connector_id, connector): self.CONNECTOR_CACHE[connector_id] = connector # 模块导入实现单例模式 connector_cache = ConnectorCacheManage()