Skip to content

Conversation

@agkloop
Copy link
Owner

@agkloop agkloop commented Dec 23, 2025

No description provided.

Copy link

Copilot AI left a 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 using asyncio.iscoroutinefunction()
  • Unified scheduling architecture using APScheduler's AsyncIOScheduler for async jobs and BackgroundScheduler for sync jobs via new SharedAsyncScheduler and SharedScheduler singletons
  • Complete test suite migration to pytest-asyncio with 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.

@agkloop agkloop merged commit e1aab07 into main Dec 23, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants