Description
The API for clearing cache on async decorated functions is inconsistent with sync functions.
Evidence
# Sync — cache_clear() works
@cache(backend=None, ttl=300)
def sync_fn(x): return x * 2
sync_fn.cache_clear() # ✓
# Async — cache_clear() raises TypeError, must use ainvalidate_cache()
@cache(backend=None, ttl=300)
async def async_fn(x): return x * 2
async_fn.cache_clear() # TypeError
await async_fn.ainvalidate_cache() # ✓ (must be awaited)
Impact
- Inconsistent API surface between sync and async decorators
- Users expect
cache_clear() to work on all decorated functions (it's stdlib convention from lru_cache)
- Not documented anywhere
Suggested Fix
Either:
- Make
cache_clear() work synchronously on async functions too (preferred — matches lru_cache convention)
- Or document the
ainvalidate_cache() requirement prominently in API reference and getting-started
Found by: tests/competitive/test_head_to_head.py::TestAsyncSupport
Description
The API for clearing cache on async decorated functions is inconsistent with sync functions.
Evidence
Impact
cache_clear()to work on all decorated functions (it's stdlib convention fromlru_cache)Suggested Fix
Either:
cache_clear()work synchronously on async functions too (preferred — matches lru_cache convention)ainvalidate_cache()requirement prominently in API reference and getting-startedFound by:
tests/competitive/test_head_to_head.py::TestAsyncSupport