From b4ef81dae69b6750f8eeb42ef424904f6710982d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Wed, 6 Sep 2023 15:53:02 +0800 Subject: [PATCH] :art: Update code style in `utils/enkanetwork.py` --- utils/enkanetwork.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/utils/enkanetwork.py b/utils/enkanetwork.py index 8ec7c84..fe60c8c 100644 --- a/utils/enkanetwork.py +++ b/utils/enkanetwork.py @@ -19,7 +19,19 @@ except ImportError: if TYPE_CHECKING: from redis import asyncio as aioredis -__all__ = ("RedisCache",) +__all__ = ("RedisCache", "StaticCache", "HTTPClient", "EnkaNetworkAPI") + + +class StaticCache(Cache): + def __init__(self, maxsize: int, ttl: int) -> None: + self.cache = TTLCache(maxsize, ttl) + + async def get(self, key) -> Dict[str, Any]: + data = self.cache.get(key) + return jsonlib.loads(data) if data is not None else data + + async def set(self, key, value) -> None: + self.cache[key] = jsonlib.dumps(value) class RedisCache(Cache): @@ -100,18 +112,6 @@ class HTTPClient(_HTTPClient): return {"status": response.status_code, "content": response.content} -class StaticCache(Cache): - def __init__(self, maxsize: int, ttl: int) -> None: - self.cache = TTLCache(maxsize, ttl) - - async def get(self, key) -> Dict[str, Any]: - data = self.cache.get(key) - return jsonlib.loads(data) if data is not None else data - - async def set(self, key, value) -> None: - self.cache[key] = jsonlib.dumps(value) - - class EnkaNetworkAPI(_EnkaNetworkAPI): def __init__( self,