aiocache icon indicating copy to clipboard operation
aiocache copied to clipboard

get cache key for decorated functions with object arguments

Open jmmaa opened this issue 1 year ago • 0 comments

How to get the cache key if I have a cached function like this?

@cached(ttl=30, serializer=PickleSerializer())
async def fetchrow_from_db(pool: asyncpg.Pool, id: int):

    record = await pool.fetchrow("SELECT * FROM my_table WHERE id = $1", id)
    return record


async def get_cache(pool: asyncpg.Pool, id: int):
    record = await fetchrow_from_db.cache.get(...) # how to get in here?

jmmaa avatar Jul 27 '22 09:07 jmmaa