Open honjes opened 2 months ago
The current implementation of the caching function works across all routes and prevents the overhead of a fetch request if the requested path exists in the redis instance. I think moving it inside of the functions would lead to a lot of duplicated code and cause issues if we ever needed to update the cache, as we would want all instances to act the same way. I think we could abstract the caching function into its own js file to make it easier to read and understand though.
Yes, I think moving the overhead to another file to make it easier to understand would be the right call if we did this. I think there would be a lot of performance improvements when doing it that way, because of the overhead each request adds to the scraping of a site.
i think it would be better if the caching would happen inside the functions, so api function could call each other without the overhead of a fetch request.
it would probably be best to give the connection object to the function to do not have to make a new connection every time.