feat 清理缓存时清理种子缓存

This commit is contained in:
jxxghp
2023-11-20 10:56:28 +08:00
parent a7752ceb17
commit 4c230b4c1e
5 changed files with 24 additions and 2 deletions

View File

@ -192,7 +192,7 @@ class DownloadChain(ChainBase):
channel=channel, channel=channel,
userid=userid) userid=userid)
if not content: if not content:
return return None
else: else:
content = torrent_file content = torrent_file
# 获取种子文件的文件夹名和文件清单 # 获取种子文件的文件夹名和文件清单

View File

@ -60,6 +60,15 @@ class TorrentsChain(ChainBase, metaclass=Singleton):
else: else:
return self.load_cache(self._rss_file) or {} return self.load_cache(self._rss_file) or {}
def clear_torrents(self):
"""
清理种子缓存数据
"""
logger.info(f'开始清理种子缓存数据 ...')
self.remove_cache(self._spider_file)
self.remove_cache(self._rss_file)
logger.info(f'种子缓存数据清理完成')
@cached(cache=TTLCache(maxsize=128, ttl=595)) @cached(cache=TTLCache(maxsize=128, ttl=595))
def browse(self, domain: str) -> List[TorrentInfo]: def browse(self, domain: str) -> List[TorrentInfo]:
""" """

View File

@ -705,8 +705,10 @@ class DoubanModule(_ModuleBase):
""" """
清除缓存 清除缓存
""" """
logger.info("开始清除豆瓣缓存 ...")
self.doubanapi.clear_cache() self.doubanapi.clear_cache()
self.cache.clear() self.cache.clear()
logger.info("豆瓣缓存清除完成")
def douban_movie_credits(self, doubanid: str, page: int = 1, count: int = 20) -> List[dict]: def douban_movie_credits(self, doubanid: str, page: int = 1, count: int = 20) -> List[dict]:
""" """

View File

@ -447,5 +447,7 @@ class TheMovieDbModule(_ModuleBase):
""" """
清除缓存 清除缓存
""" """
logger.info("开始清除TMDB缓存 ...")
self.tmdb.clear_cache() self.tmdb.clear_cache()
self.cache.clear() self.cache.clear()
logger.info("TMDB缓存清除完成")

View File

@ -13,6 +13,7 @@ from app.chain.cookiecloud import CookieCloudChain
from app.chain.mediaserver import MediaServerChain from app.chain.mediaserver import MediaServerChain
from app.chain.subscribe import SubscribeChain from app.chain.subscribe import SubscribeChain
from app.chain.tmdb import TmdbChain from app.chain.tmdb import TmdbChain
from app.chain.torrents import TorrentsChain
from app.chain.transfer import TransferChain from app.chain.transfer import TransferChain
from app.core.config import settings from app.core.config import settings
from app.log import logger from app.log import logger
@ -43,6 +44,14 @@ class Scheduler(metaclass=Singleton):
_event = threading.Event() _event = threading.Event()
def __init__(self): def __init__(self):
def clear_cache():
"""
清理缓存
"""
TorrentsChain().clear_cache()
SchedulerChain().clear_cache()
# 各服务的运行状态 # 各服务的运行状态
self._jobs = { self._jobs = {
"cookiecloud": { "cookiecloud": {
@ -73,7 +82,7 @@ class Scheduler(metaclass=Singleton):
"running": False, "running": False,
}, },
"clear_cache": { "clear_cache": {
"func": SchedulerChain().clear_cache, "func": clear_cache,
"running": False, "running": False,
} }
} }