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

Implement caching mechanism in the library #37

Merged
merged 13 commits into from
Sep 7, 2024

Conversation

ahasunos
Copy link
Owner

@ahasunos ahasunos commented Sep 7, 2024

Description

This PR introduces a caching mechanism to the library.

The new caching feature is designed to improve the performance and efficiency of API calls by reducing redundant requests and utilizing cached responses where appropriate.

Key Changes:

  • Implemented the CachePolicy class to manage caching behavior, including setting global TTLs, custom TTLs for specific endpoints, and controlling cache usage on a per-endpoint basis.
  • Added the fetch method to handle caching logic, allowing users to retrieve data from the cache or fetch fresh data as needed.
  • Provided flexibility for users to extend the caching mechanism with custom cache stores.
  • Updated the FaradayClient class to integrate with the new caching policy, applying caching logic based on the CachePolicy settings.

Related Issue

Fixes #32

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

- Added CachePolicy class to manage cache settings and TTLs
- Added CacheStore class for in-memory caching

Signed-off-by: Sonu Saha <ahasunos@gmail.com>
- Added tests for CacheStore to verify data caching, TTL expiration, and data deletion.

Signed-off-by: Sonu Saha <ahasunos@gmail.com>
- Added tests for CachePolicy to ensure correct caching behavior and TTL handling.
- Updated specs to verify cache behavior with and without forced refresh.

Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
- Updated FaradayClient to apply caching based on CachePolicy settings.
- Configured Faraday to use HTTP caching middleware conditionally.

Signed-off-by: Sonu Saha <ahasunos@gmail.com>
- Added tests for FaradayClient to ensure it handles caching and connection errors properly.
- Added tests for APIManager to verify correct data fetching and cache handling.- Updated specs to cover endpoint validation and cache refresh scenarios.

Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
Signed-off-by: Sonu Saha <ahasunos@gmail.com>
@ahasunos ahasunos merged commit fac9d2e into main Sep 7, 2024
8 checks passed
@ahasunos ahasunos deleted the feat/implement-caching-mechanism branch September 7, 2024 12:47
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.

Implement caching mechanism to enhance API performance
1 participant