Optimize ListRedisScheduleSource: replace SCAN with sorted set time index#121
Open
tmkarthi wants to merge 5 commits intotaskiq-python:mainfrom
Open
Optimize ListRedisScheduleSource: replace SCAN with sorted set time index#121tmkarthi wants to merge 5 commits intotaskiq-python:mainfrom
tmkarthi wants to merge 5 commits intotaskiq-python:mainfrom
Conversation
- Introduced `populate_time_index` parameter to backfill the time index from existing keys. - Updated `startup` method to populate the time index if `populate_time_index` is set to True. - Modified schedule addition and deletion to manage the time index sorted set. - Added tests to verify time index population and cleanup behavior.
- Added `_maybe_cleanup_time_index` method to manage time index cleanup at most once per minute. - Introduced `_cleanup_time_index` method to remove stale entries older than one hour with empty time key lists. - Updated `delete_schedule` to call `_maybe_cleanup_time_index` for efficient cleanup. - Enhanced tests to verify the behavior of the new cleanup methods, ensuring proper handling of stale and recent entries.
…ameter - Updated the _get_previous_time_schedules method to take current_time as an argument, allowing for more precise cutoff calculations. - Adjusted the logic to use the provided current_time for determining previous schedules, ensuring no overlap with the current window. - Modified the call to _get_previous_time_schedules in the first run logic to pass the current_time parameter.
- Removed the `_is_first_run` flag to simplify the schedule fetching logic. - Updated `get_schedules` to fetch past time schedules on every call, ensuring no schedules are missed within the current minute and previous minute. - Enhanced documentation to reflect the new behavior of schedule retrieval.
- Expanded README to include details on interval tasks and the new `{prefix}:time_index` sorted set for tracking schedules.
- Updated cleanup logic in `ListRedisScheduleSource` to remove stale entries older than 5 minutes instead of 1 hour.
- Modified tests to reflect the new 5-minute threshold for cleanup, ensuring accurate verification of the time index behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan