fix plugin cache

This commit is contained in:
jxxghp
2025-09-08 13:27:32 +08:00
parent 1e94d794ed
commit 59a54d4f04
3 changed files with 27 additions and 69 deletions
+9
View File
@@ -17,6 +17,7 @@ from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
from app import schemas
from app.core.cache import cached
from app.core.config import settings
from app.core.event import eventmanager, Event
from app.db.plugindata_oper import PluginDataOper
@@ -863,10 +864,14 @@ class PluginManager(metaclass=Singleton):
"""
return list(self._running_plugins.keys())
@cached(maxsize=1, ttl=1800)
def get_online_plugins(self, force: bool = False) -> List[schemas.Plugin]:
"""
获取所有在线插件信息
"""
if force:
self.get_online_plugins.cache_clear()
if not settings.PLUGIN_MARKET:
return []
@@ -1162,11 +1167,15 @@ class PluginManager(metaclass=Singleton):
return plugin
@cached(maxsize=1, ttl=1800)
async def async_get_online_plugins(self, force: bool = False) -> List[schemas.Plugin]:
"""
异步获取所有在线插件信息
:param force: 是否强制刷新(忽略缓存)
"""
if force:
await self.async_get_online_plugins.cache_clear()
if not settings.PLUGIN_MARKET:
return []