-
Notifications
You must be signed in to change notification settings - Fork 0
asyncio support #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces comprehensive async/await support to the advanced-caching library (v0.2.0), transforming it into a fully async-native caching solution while maintaining backward compatibility with synchronous functions.
Key Changes:
- All three caching decorators (
TTLCache,SWRCache,BGCache) now intelligently detect and preserve the async/sync nature of decorated functions usingasyncio.iscoroutinefunction() - Unified scheduling architecture using APScheduler's
AsyncIOSchedulerfor async jobs andBackgroundSchedulerfor sync jobs via newSharedAsyncSchedulerandSharedSchedulersingletons - Complete test suite migration to
pytest-asynciowith async-first test patterns
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Updated dependencies to include pytest-asyncio 1.3.0 and backports-asyncio-runner for Python <3.11 |
pyproject.toml |
Added pytest-asyncio dependency and asyncio test configuration |
src/advanced_caching/decorators.py |
Refactored TTL/SWR/BG decorators to support both sync and async functions natively with dual wrapper implementations |
src/advanced_caching/_schedulers.py |
New module providing SharedScheduler and SharedAsyncScheduler singleton classes for background job management |
src/advanced_caching/_decorator_common.py |
New helper module with cache factory normalization and wrapper metadata attachment utilities |
src/advanced_caching/storage.py |
Minor optimization replacing entry.is_fresh(now) with direct timestamp comparison |
src/advanced_caching/__init__.py |
Updated exports to include new async-prefixed class names and bumped version to 0.2.0 |
tests/test_sync_support.py |
New test file verifying sync functions remain sync and async functions remain async after decoration |
tests/test_integration_redis.py |
Converted all test classes to async with @pytest.mark.asyncio decorator |
tests/test_correctness.py |
Converted all tests to async-first patterns, replacing time.sleep() with await asyncio.sleep() |
tests/benchmark.py |
Simplified to async-only hot cache hit benchmarks, removing cold/mixed scenarios and comparison tooling |
tests/compare_benchmarks.py |
Removed (248 lines deleted) - benchmark comparison functionality |
docs/benchmarking.md |
Removed (260 lines deleted) - detailed benchmarking guide |
docs/benchmarking-and-profiling.md |
Updated to reflect async-only architecture and simplified benchmark suite |
README.md |
Enhanced examples showing both sync and async usage patterns for all decorators |
CHANGELOG.md |
Documented v0.2.0 changes with architecture overhaul details |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.