followers-cache-fixes
This commit is contained in:
parent
977b86a3c6
commit
5e8b7cfe98
|
@ -27,7 +27,7 @@ async def update_author_cache(author: dict, ttl=25 * 60 * 60):
|
||||||
|
|
||||||
async def update_author_followers_cache(author_id: int, followers, ttl=25 * 60 * 60):
|
async def update_author_followers_cache(author_id: int, followers, ttl=25 * 60 * 60):
|
||||||
payload = json.dumps(followers)
|
payload = json.dumps(followers)
|
||||||
await redis.execute('SET', f'author:{author_id}:followers', payload)
|
await redis.execute('SETEX', f'author:{author_id}:followers', ttl, payload)
|
||||||
|
|
||||||
|
|
||||||
async def update_follows_topics_cache(follows, author_id: int, ttl=25 * 60 * 60):
|
async def update_follows_topics_cache(follows, author_id: int, ttl=25 * 60 * 60):
|
||||||
|
@ -157,9 +157,9 @@ async def update_followers_for_author(follower: Author, author: Author, is_inser
|
||||||
if is_insert:
|
if is_insert:
|
||||||
followers.append(follower)
|
followers.append(follower)
|
||||||
else:
|
else:
|
||||||
# Remove the entity from follows
|
# Remove the entity from followers
|
||||||
follows = [e for e in followers if e['id'] != author.id]
|
followers = [e for e in followers if e['id'] != author.id]
|
||||||
await redis.execute('SETEX', redis_key, ttl, json.dumps(follows))
|
await redis.execute('SETEX', redis_key, ttl, json.dumps(followers))
|
||||||
|
|
||||||
|
|
||||||
async def handle_author_follower_change(
|
async def handle_author_follower_change(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user