cachier icon indicating copy to clipboard operation
cachier copied to clipboard

Support for coroutines (asyncio)

Open dekked opened this issue 4 years ago • 3 comments

Hello,

I was trying to use cachier for caching the result of functions, in particular, HTTP requests.

I am using asyncio throughout my code. I noticed that cachier is fully synchronous, as seen here when calling _calc_entry.

It would be great to have support for caching result of coroutines, using await.

Maybe an async PickeCore / decorator? I am not clear on the best way to accomplish this with minimal code duplication, though.

dekked avatar May 09 '20 18:05 dekked

Hey,

That's an interesting use case. Yeah, I'm not sure myself. I think duplicating the decorator in a way that is agnostic to the core being used would be best, but this might also require rewriting the cores themselves to some extent. Also, it might simply be too complicated or plain impossible to have cores support this agnostically, and so each core would perhaps have to have a separate async implementation. But the pickle one is the important one anyway, I think.

I guess you'd have to figure things out a bit more before I can help you with this, as I really don't have the time to dive into this problem myself.

shaypal5 avatar May 14 '20 11:05 shaypal5