fix async apis

This commit is contained in:
jxxghp
2025-08-01 20:27:22 +08:00
parent cc69d3b8d1
commit e32b6e07b4
7 changed files with 79 additions and 44 deletions
+24
View File
@@ -60,6 +60,21 @@ class TorrentsChain(ChainBase):
else:
return self.load_cache(self._rss_file) or {}
async def async_get_torrents(self, stype: Optional[str] = None) -> Dict[str, List[Context]]:
"""
异步获取当前缓存的种子
:param stype: 强制指定缓存类型,spider:爬虫缓存,rss:rss缓存
"""
if not stype:
stype = settings.SUBSCRIBE_MODE
# 异步读取缓存
if stype == 'spider':
return await self.async_load_cache(self._spider_file) or {}
else:
return await self.async_load_cache(self._rss_file) or {}
def clear_torrents(self):
"""
清理种子缓存数据
@@ -69,6 +84,15 @@ class TorrentsChain(ChainBase):
self.remove_cache(self._rss_file)
logger.info(f'种子缓存数据清理完成')
async def async_clear_torrents(self):
"""
异步清理种子缓存数据
"""
logger.info(f'开始异步清理种子缓存数据 ...')
await self.async_remove_cache(self._spider_file)
await self.async_remove_cache(self._rss_file)
logger.info(f'异步种子缓存数据清理完成')
def browse(self, domain: str, keyword: Optional[str] = None, cat: Optional[str] = None,
page: Optional[int] = 0) -> List[TorrentInfo]:
"""