mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-21 14:48:29 +00:00
🎨 Update code style in utils/enkanetwork.py
This commit is contained in:
parent
f1de1c987d
commit
b4ef81dae6
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user