mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Move RSS compression to Redis module, fix crash
This commit is contained in:
parent
3a076a9b4e
commit
091bb6813d
2 changed files with 11 additions and 9 deletions
|
|
@ -102,7 +102,7 @@ proc cache*(data: Tweet) {.async.} =
|
|||
proc cacheRss*(query: string; rss: Rss) {.async.} =
|
||||
let key = "rss:" & query
|
||||
pool.withAcquire(r):
|
||||
dawait r.hSet(key, "rss", rss.feed)
|
||||
dawait r.hSet(key, "rss", compress(rss.feed))
|
||||
dawait r.hSet(key, "min", rss.cursor)
|
||||
dawait r.expire(key, rssCacheTime)
|
||||
|
||||
|
|
@ -182,6 +182,9 @@ proc getCachedRss*(key: string): Future[Rss] {.async.} =
|
|||
pool.withAcquire(r):
|
||||
result.cursor = await r.hGet(k, "min")
|
||||
if result.cursor.len > 2:
|
||||
result.feed = await r.hGet(k, "rss")
|
||||
let feed = await r.hGet(k, "rss")
|
||||
if feed != redisNil:
|
||||
try: result.feed = uncompress feed
|
||||
except: echo "Decompressing RSS failed: ", feed
|
||||
else:
|
||||
result.cursor.setLen 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue