Release Notes v0.4.4
π New Features
Cache Metadata Tracking
- Added
from_cachemetadata field to all task responses and status objects - Tasks now indicate whether their results were served from cache (
true) or freshly computed (false) - Available in all API endpoints:
/api/v1/tasks,/api/v1/tasks/{task_id}, and task listings
Enhanced Completion Callbacks
- Updated completion callback signature to include cache metadata:
(task_id, result, from_cache) - Backward compatibility maintained - existing callbacks without the
from_cacheparameter continue to work - Cache hits and fresh computations are now distinguishable in callback handlers
π§ Improvements
API Enhancements
- All task response models now include the
from_cacheboolean field - Task serialization (
.to_dict()) includes cache metadata - Consistent cache metadata across all task management operations
Testing
- Added comprehensive test coverage for cache metadata functionality
- Tests verify cache metadata in both direct task execution and API responses
- Ensures cache metadata is properly serialized and deserialized
π¦ Dependencies
- Updated redis:
6.1.0β6.2.0
π Breaking Changes
None - This release maintains full backward compatibility with existing code.
π‘ Usage Examples
Checking if a result came from cache:
task_info = await worker.get_task_info(task_id)
if task_info.from_cache:
print("Result was served from cache")
else:
print("Result was freshly computed")Using the enhanced completion callback:
async def on_task_complete(task_id: str, result: Any, from_cache: bool):
if from_cache:
logger.info(f"Cache hit for task {task_id}")
else:
logger.info(f"Fresh computation for task {task_id}")
# Old callbacks still work:
async def legacy_callback(task_id: str, result: Any):
logger.info(f"Task {task_id} completed")API Response Example:
{
"id": "task-123",
"status": "completed",
"result": {"value": "computed_result"},
"from_cache": true,
"progress": 1.0,
"metadata": {}
}This release enhances observability and debugging capabilities while maintaining full backward compatibility with existing applications.