cache-reform
This commit is contained in:
@@ -204,7 +204,21 @@ async def get_authors_with_stat_cached(q):
|
||||
records = []
|
||||
with local_session() as session:
|
||||
for x in session.execute(q):
|
||||
stat_str = await redis.execute('GET', f'id:{x.id}:{'author'}')
|
||||
stat_str = await redis.execute('GET', f'author:{x.id}')
|
||||
if isinstance(stat_str, str):
|
||||
x.stat = json.loads(stat_str).get('stat')
|
||||
records.append(x)
|
||||
except Exception as exc:
|
||||
raise Exception(exc)
|
||||
return records
|
||||
|
||||
|
||||
async def get_topics_with_stat_cached(q):
|
||||
try:
|
||||
records = []
|
||||
with local_session() as session:
|
||||
for x in session.execute(q):
|
||||
stat_str = await redis.execute('GET', f'topic:{x.id}')
|
||||
if isinstance(stat_str, str):
|
||||
x.stat = json.loads(stat_str).get('stat')
|
||||
records.append(x)
|
||||
|
Reference in New Issue
Block a user