1
0
mirror of https://github.com/zedeus/nitter.git synced 2025-12-06 03:55:36 -05:00

Optimize profile caching strategy

This commit is contained in:
Zed
2020-06-09 18:19:20 +02:00
parent ba9ba3a55e
commit 61d27efd69
2 changed files with 20 additions and 8 deletions

View File

@@ -85,12 +85,14 @@ proc getProfileId*(username: string): Future[string] {.async.} =
if result == redisNil:
result.setLen(0)
proc getCachedProfile*(username: string; fetch=true): Future[Profile] {.async.} =
proc getCachedProfile*(username: string; fetch=true;
cache=false): Future[Profile] {.async.} =
let prof = await get("p:" & toLower(username))
if prof != redisNil:
uncompress(prof).thaw(result)
elif fetch:
result = await getProfile(username)
if cache: await cache(result)
proc getCachedPhotoRail*(id: string): Future[PhotoRail] {.async.} =
if id.len == 0: return