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

Encapsulate caching logic into separate module #615

Open
okis-netlight opened this issue Feb 12, 2025 · 0 comments
Open

Encapsulate caching logic into separate module #615

okis-netlight opened this issue Feb 12, 2025 · 0 comments

Comments

@okis-netlight
Copy link
Contributor

okis-netlight commented Feb 12, 2025

Currently, the caching logic is written in the API routes. In order to facilitate the reuse in potential other routes and clean up API route code, it would be beneficial to create a reusable module that reads and udates the cache. This involves the following steps:

  • Create a new module containing caching logic. This should provide functionality for reading from the cache, and automatically refreshing the cache on a miss. You could possibly use a callback to specify how to fetch new data from the DB.
  • Move caching logic from API routes to the new caching module.
  • Create a middleware that calls the caching module for requests that need to be cached. (Might not be necessary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants