Skip to content

Release v0.4.4

Latest

Choose a tag to compare

@oranheim oranheim released this 28 May 09:02
· 19 commits to master since this release

Release Notes v0.4.4

πŸš€ New Features

Cache Metadata Tracking

  • Added from_cache metadata 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_cache parameter 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_cache boolean 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.