You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to get the cache key if I have a cached function like this?
@cached(ttl=30, serializer=PickleSerializer())asyncdeffetchrow_from_db(pool: asyncpg.Pool, id: int):
record=awaitpool.fetchrow("SELECT * FROM my_table WHERE id = $1", id)
returnrecordasyncdefget_cache(pool: asyncpg.Pool, id: int):
record=awaitfetchrow_from_db.cache.get(...) # how to get in here?
The text was updated successfully, but these errors were encountered:
Why not just do await fetchrow_from_db(pool, id)? That'll obviously get the result from the cache.
Actually, I went into a deep rabbit hole in this one.
I really wanted a flexible way of invalidating cache in a simple, functional way in my discord bot. Turns out that invalidating cache in an atomic way is way too complex.
So yeah I just made my own cache class which is a singleton that I can reuse it in other parts of my bot
How to get the cache key if I have a cached function like this?
The text was updated successfully, but these errors were encountered: