mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
parent
17ad0fec34
commit
db5a229bfe
11 changed files with 379 additions and 3 deletions
|
|
@ -173,6 +173,21 @@ proc getCachedBroadcast*(id: string): Future[Broadcast] {.async.} =
|
|||
await cache(result)
|
||||
result.m3u8Url = await fetchBroadcastStream(result.mediaKey)
|
||||
|
||||
proc cache*(data: AudioSpace) {.async.} =
|
||||
if data.id.len == 0: return
|
||||
let ttl = if data.state == "RUNNING": baseCacheTime div 6 else: baseCacheTime
|
||||
await setEx("sp:" & data.id, ttl, compress(toFlatty(data)))
|
||||
|
||||
proc getCachedAudioSpace*(id: string): Future[AudioSpace] {.async.} =
|
||||
if id.len == 0: return
|
||||
let cached = await get("sp:" & id)
|
||||
if cached != redisNil:
|
||||
cached.deserialize(AudioSpace)
|
||||
else:
|
||||
result = await getAudioSpace(id)
|
||||
await cache(result)
|
||||
result.m3u8Url = await fetchBroadcastStream(result.mediaKey)
|
||||
|
||||
proc cache*(data: AccountInfo; name: string) {.async.} =
|
||||
await setEx("ai:" & toLower(name), baseCacheTime * 24, compress(toFlatty(data)))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue