Rework list api
This commit is contained in:
@@ -56,7 +56,7 @@ proc initRedisPool*(cfg: Config) {.async.} =
|
||||
|
||||
template pidKey(name: string): string = "pid:" & $(hash(name) div 1_000_000)
|
||||
template profileKey(name: string): string = "p:" & name
|
||||
template listKey(l: List): string = toLower("l:" & l.username & '/' & l.name)
|
||||
template listKey(l: List): string = "l:" & l.id
|
||||
|
||||
proc get(query: string): Future[string] {.async.} =
|
||||
pool.withAcquire(r):
|
||||
@@ -129,17 +129,17 @@ proc getCachedPhotoRail*(name: string): Future[PhotoRail] {.async.} =
|
||||
result = await getPhotoRail(name)
|
||||
await cache(result, name)
|
||||
|
||||
proc getCachedList*(username=""; name=""; id=""): Future[List] {.async.} =
|
||||
let list = if id.len > 0: redisNil
|
||||
else: await get(toLower("l:" & username & '/' & name))
|
||||
proc getCachedList*(username=""; slug=""; id=""): Future[List] {.async.} =
|
||||
let list = if id.len == 0: redisNil
|
||||
else: await get("l:" & id)
|
||||
|
||||
if list != redisNil:
|
||||
result = fromFlatty(uncompress(list), List)
|
||||
else:
|
||||
if id.len > 0:
|
||||
result = await getGraphListById(id)
|
||||
result = await getGraphList(id)
|
||||
else:
|
||||
result = await getGraphList(username, name)
|
||||
result = await getGraphListBySlug(username, slug)
|
||||
await cache(result)
|
||||
|
||||
proc getCachedRss*(key: string): Future[Rss] {.async.} =
|
||||
|
||||
Reference in New Issue
Block a user