Decorating async functions?
Hi:
This may be simple, but I can't find in the docs or the code: How do I cache the results of an async function? I'm getting an error that a coroutine isn't JSON serializable which is true, but is there a way to tell redis-cache to await instead of caching the coro itself? Or would that be a simple change to submit a PR for?
Thanks much!
The library currently doesn’t support async. I would be happy to accept a PR for async with tests.
Thanks for confirming. Can you give me a hint where we're start for the PR? I will see if I can hack it... (with tests)
Message ID: @.*** com>
Here is around the line that you would need to change:
https://github.com/taylorhakes/python-redis-cache/blob/master/redis_cache/init.py#L208
Here are some links on what needs to be done:
https://n8henrie.com/2021/11/decorator-to-memoize-sync-or-async-functions-in-python/
https://stackoverflow.com/questions/68410730/how-to-make-decorator-work-with-async-function
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.