Skip to content

Commit

Permalink
chore: aiocacheを廃止
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Oct 31, 2022
1 parent 94d4715 commit 9f49870
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ sphinx
furo
sphinxcontrib_trio
aiohttp
aiocache

11 changes: 3 additions & 8 deletions mipac/actions/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

from typing import TYPE_CHECKING, Optional

from aiocache import Cache, cached

from mipac.exception import NotExistRequiredData, ParameterError
from mipac.http import HTTPClient, Route
from mipac.manager.note import NoteManager
from mipac.util import (
cache,
check_multi_arg,
get_cache_key,
key_builder,
remove_dict_empty,
)

Expand Down Expand Up @@ -42,7 +40,7 @@ async def get_me(self) -> UserDetailed:
res = await self.__session.request(Route('POST', '/api/i'), auth=True)
return UserDetailed(res, client=self.__client) # TODO: 自分用のクラスに変更する

@cached(ttl=10, namespace='get_user', key_builder=key_builder)
@cache(group='get_user')
async def get(
self,
user_id: Optional[str] = None,
Expand Down Expand Up @@ -76,13 +74,12 @@ async def get(
)
return UserDetailed(data, client=self.__client)

@get_cache_key
@cache
async def fetch(
self,
user_id: Optional[str] = None,
username: Optional[str] = None,
host: Optional[str] = None,
**kwargs,
) -> UserDetailed:
"""
サーバーにアクセスし、ユーザーのプロフィールを取得します。基本的には get_userをお使いください。
Expand Down Expand Up @@ -110,8 +107,6 @@ async def fetch(
data = await self.__session.request(
Route('POST', '/api/users/show'), json=field, auth=True, lower=True
)
old_cache = Cache(namespace='get_user')
await old_cache.delete(kwargs['cache_key'].format('get_user'))
return UserDetailed(data, client=self.__client)

async def get_notes(
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
aiohttp
aiocache

0 comments on commit 9f49870

Please sign in to comment.