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 1-Day Caching for getPurchases API Calls #196

Closed
wants to merge 1 commit into from

Conversation

TanmayDhobale
Copy link
Contributor

Changes Made

  • Added an in-memory caching object to store the results of getPurchases calls.
  • Implemented logic within getPurchases to check for valid cached data before proceeding with API calls.
  • Cached data is stored with a timestamp to ensure it's only used for up to 24 hours, after which it's refreshed on the next call.
  • This caching mechanism is applied conditionally, so it only caches data when the environment does not rely on the local CMS provider for course information.

Benefits

  • Reduced API Calls: Significantly decreases the number of external API requests, lowering our server load and potential costs.
  • Improved Performance: Users will experience faster response times when accessing their purchases, enhancing overall user satisfaction.
  • Scalability: Reduces the risk of hitting API rate limits as our user base grows.

Considerations-
The current implementation is an in-memory cache, which means cached data is reset if the server restarts. For long-term scalability, we may consider using a more persistent caching solution like Redis.
-We'll need to monitor the memory usage on our server to ensure the cache does not grow too large.

@hkirat
Copy link
Contributor

hkirat commented Mar 11, 2024

Please use https://github.com/code100x/cms/blob/main/src/db/Cache.ts
generify this to take the expiry as an input

@TanmayDhobale
Copy link
Contributor Author

TanmayDhobale commented Mar 11, 2024

@hkirat can u pls check #199

@hkirat
Copy link
Contributor

hkirat commented Mar 11, 2024

Closing in favor of #208

@hkirat hkirat closed this Mar 11, 2024
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.

2 participants