diff --git a/resolvers/author.py b/resolvers/author.py index 168ee9b1..14b02395 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -143,7 +143,7 @@ async def get_author_follows(_, _info, slug='', user=None, author_id=None): ) author_id = author_id_result[0] if author_id_result else None if author_id: - rkey = f'id:{author_id}:follows-authors' + rkey = f'author:{author_id}:follows-authors' logger.debug(f'getting {author_id} follows authors') cached = await redis.execute('GET', rkey) # logger.debug(f'AUTHOR CACHED {cached}') @@ -152,7 +152,7 @@ async def get_author_follows(_, _info, slug='', user=None, author_id=None): prepared = [author.dict() for author in authors] await redis.execute('SETEX', rkey, 24*60*60, json.dumps(prepared)) - rkey = f'id:{author_id}:follows-topics' + rkey = f'author:{author_id}:follows-topics' cached = await redis.execute('GET', rkey) topics = json.loads(cached) if cached else author_follows_topics(author_id) if not cached: @@ -181,7 +181,7 @@ async def get_author_follows_topics(_, _info, slug='', user=None, author_id=None author_id = author_id_result[0] if author_id_result else None if author_id: logger.debug(f'getting {author_id} follows topics') - rkey = f'id:{author_id}:follows-topics' + rkey = f'author:{author_id}:follows-topics' cached = await redis.execute('GET', rkey) topics = json.loads(cached) if cached else author_follows_topics(author_id) if not cached: @@ -204,7 +204,7 @@ async def get_author_follows_authors(_, _info, slug='', user=None, author_id=Non author_id = author_id_result[0] if author_id_result else None if author_id: logger.debug(f'getting {author_id} follows authors') - rkey = f'id:{author_id}:follows-authors' + rkey = f'author:{author_id}:follows-authors' cached = await redis.execute('GET', rkey) authors = json.loads(cached) if cached else author_follows_authors(author_id) if not cached: @@ -231,7 +231,7 @@ async def get_author_followers(_, _info, slug: str): author_alias = aliased(Author) author_id = session.query(author_alias.id).filter(author_alias.slug == slug).scalar() if author_id: - cached = await redis.execute('GET', f'id:{author_id}:followers') + cached = await redis.execute('GET', f'author:{author_id}:followers') results = [] if not cached: author_follower_alias = aliased(AuthorFollower, name='af') diff --git a/services/cache.py b/services/cache.py index 472cfdec..32dba733 100644 --- a/services/cache.py +++ b/services/cache.py @@ -138,7 +138,7 @@ def after_author_follower_delete(mapper, connection, target: AuthorFollower): async def update_follows_for_author(follower: Author, entity_type: str, entity: dict, is_insert: bool): ttl = 25 * 60 * 60 - redis_key = f'id:{follower.id}:follows-{entity_type}s' + redis_key = f'author:{follower.id}:follows-{entity_type}s' follows_str = await redis.get(redis_key) follows = json.loads(follows_str) if follows_str else [] if is_insert: @@ -151,7 +151,7 @@ async def update_follows_for_author(follower: Author, entity_type: str, entity: async def update_followers_for_author(follower: Author, author: Author, is_insert: bool): ttl = 25 * 60 * 60 - redis_key = f'id:{author.id}:followers' + redis_key = f'author:{author.id}:followers' followers_str = await redis.get(redis_key) followers = json.loads(followers_str) if followers_str else [] if is_insert: