mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix cache_clear
This commit is contained in:
@@ -105,7 +105,7 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
异步删除缓存,同时删除Redis和本地缓存
|
异步删除缓存,同时删除Redis和本地缓存
|
||||||
"""
|
"""
|
||||||
pass
|
await self.async_filecache.delete(filename)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __is_valid_empty(ret):
|
def __is_valid_empty(ret):
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ class DoubanApi(metaclass=WeakSingleton):
|
|||||||
_api_url = "https://api.douban.com/v2"
|
_api_url = "https://api.douban.com/v2"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.__clear_async_cache__ = False
|
||||||
self._session = requests.Session()
|
self._session = requests.Session()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -171,28 +172,24 @@ class DoubanApi(metaclass=WeakSingleton):
|
|||||||
).digest()
|
).digest()
|
||||||
).decode()
|
).decode()
|
||||||
|
|
||||||
@cached(maxsize=settings.CONF.douban, ttl=settings.CONF.meta)
|
|
||||||
def __invoke_recommend(self, url: str, **kwargs) -> dict:
|
def __invoke_recommend(self, url: str, **kwargs) -> dict:
|
||||||
"""
|
"""
|
||||||
推荐/发现类API
|
推荐/发现类API
|
||||||
"""
|
"""
|
||||||
return self.__invoke(url, **kwargs)
|
return self.__invoke(url, **kwargs)
|
||||||
|
|
||||||
@cached(maxsize=settings.CONF.douban, ttl=settings.CONF.meta)
|
|
||||||
async def __async_invoke_recommend(self, url: str, **kwargs) -> dict:
|
async def __async_invoke_recommend(self, url: str, **kwargs) -> dict:
|
||||||
"""
|
"""
|
||||||
推荐/发现类API(异步版本)
|
推荐/发现类API(异步版本)
|
||||||
"""
|
"""
|
||||||
return await self.__async_invoke(url, **kwargs)
|
return await self.__async_invoke(url, **kwargs)
|
||||||
|
|
||||||
@cached(maxsize=settings.CONF.douban, ttl=settings.CONF.meta)
|
|
||||||
def __invoke_search(self, url: str, **kwargs) -> dict:
|
def __invoke_search(self, url: str, **kwargs) -> dict:
|
||||||
"""
|
"""
|
||||||
搜索类API
|
搜索类API
|
||||||
"""
|
"""
|
||||||
return self.__invoke(url, **kwargs)
|
return self.__invoke(url, **kwargs)
|
||||||
|
|
||||||
@cached(maxsize=settings.CONF.douban, ttl=settings.CONF.meta)
|
|
||||||
async def __async_invoke_search(self, url: str, **kwargs) -> dict:
|
async def __async_invoke_search(self, url: str, **kwargs) -> dict:
|
||||||
"""
|
"""
|
||||||
搜索类API(异步版本)
|
搜索类API(异步版本)
|
||||||
@@ -245,6 +242,9 @@ class DoubanApi(metaclass=WeakSingleton):
|
|||||||
"""
|
"""
|
||||||
GET请求(异步版本)
|
GET请求(异步版本)
|
||||||
"""
|
"""
|
||||||
|
if self.__clear_async_cache__:
|
||||||
|
self.__clear_async_cache__ = False
|
||||||
|
await self.__async_invoke.cache_clear()
|
||||||
req_url, params = self._prepare_get_request(url, **kwargs)
|
req_url, params = self._prepare_get_request(url, **kwargs)
|
||||||
resp = await AsyncRequestUtils(
|
resp = await AsyncRequestUtils(
|
||||||
ua=choice(self._user_agents)
|
ua=choice(self._user_agents)
|
||||||
@@ -864,8 +864,8 @@ class DoubanApi(metaclass=WeakSingleton):
|
|||||||
"""
|
"""
|
||||||
清空LRU缓存
|
清空LRU缓存
|
||||||
"""
|
"""
|
||||||
# 尚未支持缓存清理
|
self.__invoke.cache_clear()
|
||||||
pass
|
self.__clear_async_cache__ = True
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self._session:
|
if self._session:
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class TMDb(object):
|
|||||||
self._timeout = 15
|
self._timeout = 15
|
||||||
self.obj_cached = obj_cached
|
self.obj_cached = obj_cached
|
||||||
|
|
||||||
|
self.__clear_async_cache__ = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def page(self):
|
def page(self):
|
||||||
return self._page
|
return self._page
|
||||||
@@ -133,6 +135,9 @@ class TMDb(object):
|
|||||||
@cached(maxsize=settings.CONF.tmdb, ttl=settings.CONF.meta, skip_none=True)
|
@cached(maxsize=settings.CONF.tmdb, ttl=settings.CONF.meta, skip_none=True)
|
||||||
async def async_cached_request(self, method, url, data, json,
|
async def async_cached_request(self, method, url, data, json,
|
||||||
_ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
_ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
|
if self.__clear_async_cache__:
|
||||||
|
self.__clear_async_cache__ = False
|
||||||
|
await self.async_cached_request.cache_clear()
|
||||||
return await self.async_request(method, url, data, json)
|
return await self.async_request(method, url, data, json)
|
||||||
|
|
||||||
def request(self, method, url, data, json):
|
def request(self, method, url, data, json):
|
||||||
@@ -154,6 +159,7 @@ class TMDb(object):
|
|||||||
return req
|
return req
|
||||||
|
|
||||||
def cache_clear(self):
|
def cache_clear(self):
|
||||||
|
self.__clear_async_cache__ = True
|
||||||
return self.cached_request.cache_clear()
|
return self.cached_request.cache_clear()
|
||||||
|
|
||||||
def _validate_api_key(self):
|
def _validate_api_key(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user