Expand current support for cache backend filter functions to allow async filtering methods.
Use case
The current implementation only allows synchronous functions as filter functions on the cache backend. This has the limitation that
any filtering decision can only make use of synchronous properties/methods of the aiohttp.ClientResponse object.
This is quite limiting, as any actual data of the response needs to be awaited before accessing it. For concrete example, consider that an API response returns a JSON object that contains a content and a success field:
response = {
"content": "...",
"success": True
}
It is really useful to be able to only cache successful (aka response.success == True) responses, and discard the rest. Ideally, one could implement a filter that looks like the following:
Feature description
Expand current support for cache backend filter functions to allow async filtering methods.
Use case
The current implementation only allows synchronous functions as filter functions on the cache backend. This has the limitation that any filtering decision can only make use of synchronous properties/methods of the aiohttp.ClientResponse object.
This is quite limiting, as any actual data of the response needs to be awaited before accessing it. For concrete example, consider that an API response returns a JSON object that contains a
content
and asuccess
field:It is really useful to be able to only cache successful (aka
response.success == True
) responses, and discard the rest. Ideally, one could implement a filter that looks like the following:Unfortunately, this is not currently supported as the filtering function is not awaited by the internal implementation