cached-all

This commit is contained in:
2024-03-12 17:26:52 +03:00
parent a3303837d5
commit e99acd591a
4 changed files with 29 additions and 17 deletions

View File

@@ -14,7 +14,7 @@ from services.cache import set_author_cache, update_author_followers_cache
from services.auth import login_required
from services.db import local_session
from services.encoders import CustomJSONEncoder
from services.memorycache import authors_cache_region
from services.memorycache import cache_region
from services.rediscache import redis
from services.schema import mutation, query
from services.logger import root_logger as logger
@@ -113,7 +113,7 @@ async def get_author_id(_, _info, user: str):
def load_authors_by(_, _info, by, limit, offset):
cache_key = f"{json.dumps(by)}_{limit}_{offset}"
@authors_cache_region.cache_on_arguments(cache_key)
@cache_region.cache_on_arguments(cache_key)
def _load_authors_by():
logger.debug(f'loading authors by {by}')
q = select(Author)
@@ -150,8 +150,6 @@ def load_authors_by(_, _info, by, limit, offset):
return _load_authors_by()
@query.field('get_author_follows')
async def get_author_follows(_, _info, slug='', user=None, author_id=None):
with (local_session() as session):