Skip to content
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

fix: implement reciter caching with timestamp validation #1517

Closed
wants to merge 1 commit into from

Conversation

YassinNouh21
Copy link
Contributor

📝 Summary

This PR fixes

Description

This PR introduces a caching mechanism for reciter data to improve performance and reduce unnecessary network calls. The changes include:

  • Added a new Hive box (_timestampBox) to track the last update time of reciter data.
  • Implemented a 30-day cache retention period in ReciteImpl to ensure data is refreshed only when outdated.
  • Added a getLastUpdatedTimestamp method to retrieve the cache timestamp.
  • Updated reciteLocalDataSourceProvider to include the new _timestampBox.
  • Modified reciteRemoteDataSourceProvider to use a direct DioModule instance for simplicity.
  • Removed redundant try-catch blocks in _getRemoteReciters for cleaner code flow.
  • Added new constants (kQuranCacheBoxName and kQuranReciterRetentionTime) for better maintainability.

These changes ensure that reciter data is cached locally and refreshed only when necessary, improving the app's performance and user experience.

Tests

🧪 Use case 1

💬 Description:
Launch the app and verify that reciter data is fetched from the cache if it was updated within the last 30 days. If the cache is outdated, ensure the data is fetched from the remote API and the cache is updated.

📷 Screenshots or GIFs (if applicable):
N/A

Checklist:

  • Coding Standards: I have reviewed my code to ensure it follows the project's coding standards.
  • Testing: I have tested the changes and they work as expected.
  • Merge Conflicts: I have resolved any merge conflicts with the latest main/development branch.
  • Branch Status: The branch is up-to-date with the target branch (main/development).

- Added `_timestampBox` to `ReciteLocalDataSource` for tracking cache updates
- Introduced caching logic with a 30-day retention period in `ReciteImpl`
- Added `getLastUpdatedTimestamp` method to retrieve cache timestamps
- Modified `reciteLocalDataSourceProvider` to include `_timestampBox`
- Updated `reciteRemoteDataSourceProvider` to use direct `DioModule` instance
@YassinNouh21 YassinNouh21 self-assigned this Dec 31, 2024
@YassinNouh21 YassinNouh21 added the bug Something isn't working label Jan 8, 2025
@ghassenbenzahra123 ghassenbenzahra123 modified the milestone: 1.19.x Jan 8, 2025
@ibrahim-zehhaf-mawaqit ibrahim-zehhaf-mawaqit deleted the branch release-1.18.0 January 23, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants