This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import asyncpg | |
async def listen_for_notifications(): | |
backoff_times = [1, 2, 4, 8, 16] # Backoff times in seconds | |
backoff_counter = 0 | |
while True: | |
try: | |
conn: asyncpg.Connection = await asyncpg.connect( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LRU_Cache<T> extends Map<string,T> { | |
private _limit: number; | |
constructor(limit: number, entries?: [string, T][]) { | |
super(entries); | |
this._limit = limit; | |
} | |
get(key: string) { | |
const hasKey = this.has(key); | |
if (!hasKey) return; |