mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
✨ 添加API缓存
This commit is contained in:
parent
b67277ae2b
commit
4707dfc08c
@ -25,3 +25,6 @@ GIT_API_TREES_FORMAT = (
|
|||||||
"https://api.github.com/repos/{owner}/{repo}/git/trees/{branch}?recursive=1"
|
"https://api.github.com/repos/{owner}/{repo}/git/trees/{branch}?recursive=1"
|
||||||
)
|
)
|
||||||
"""git api trees地址格式"""
|
"""git api trees地址格式"""
|
||||||
|
|
||||||
|
CACHED_API_TTL = 300
|
||||||
|
"""缓存api ttl"""
|
||||||
|
|||||||
@ -9,6 +9,7 @@ from zhenxun.utils.enum import PluginType
|
|||||||
from zhenxun.utils.http_utils import AsyncHttpx
|
from zhenxun.utils.http_utils import AsyncHttpx
|
||||||
|
|
||||||
from .config import (
|
from .config import (
|
||||||
|
CACHED_API_TTL,
|
||||||
GIT_API_TREES_FORMAT,
|
GIT_API_TREES_FORMAT,
|
||||||
JSD_PACKAGE_API_FORMAT,
|
JSD_PACKAGE_API_FORMAT,
|
||||||
GITHUB_REPO_URL_PATTERN,
|
GITHUB_REPO_URL_PATTERN,
|
||||||
@ -94,6 +95,7 @@ class BaseInfo(BaseModel, ABC):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
@cached(ttl=CACHED_API_TTL)
|
||||||
async def parse_repo_info(cls, repo_info: RepoInfo) -> "BaseInfo": ...
|
async def parse_repo_info(cls, repo_info: RepoInfo) -> "BaseInfo": ...
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@ -160,6 +162,7 @@ class FileInfo(BaseInfo):
|
|||||||
return cur_file
|
return cur_file
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@cached(ttl=CACHED_API_TTL)
|
||||||
async def parse_repo_info(cls, repo_info: RepoInfo) -> "FileInfo":
|
async def parse_repo_info(cls, repo_info: RepoInfo) -> "FileInfo":
|
||||||
"""解析仓库信息"""
|
"""解析仓库信息"""
|
||||||
|
|
||||||
@ -224,6 +227,7 @@ class TreesInfo(BaseInfo):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@cached(ttl=CACHED_API_TTL)
|
||||||
async def parse_repo_info(cls, repo_info: RepoInfo) -> "TreesInfo":
|
async def parse_repo_info(cls, repo_info: RepoInfo) -> "TreesInfo":
|
||||||
"""获取仓库树
|
"""获取仓库树
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user