How to add cache to your GCP Cloud functions
DRANK

Photo by Dominik Dancs on UnsplashAs I am certain you are aware, this is the month of Hacktoberfest. I wanted to display statistics about my colleagues participation to the event and display it to our website. To achieve it I needed to use GitHub API I choosed to store my query in a Google Cloud Function. It was the occasion to test this service aswell.While developping, I came across an issue. The Github API is quite long to respond nearly 2 seconds. Sometimes it takes even longer, I had a query lasting more than 10 seconds. Nobody want to wait for 10 seconds to browse a website. So I decided to add cache to my Cloud Function. How does a GCP Cloud Function works?While searching information about caching data I came across this documentation. Here is a quick summary:A Cloud Function isn't receated from scratch at each invocation. The execution environnement is preserved between invocations but it is not guaranted. You can use global variable to store results of heavy computations.Soun…

yvonnickfrin.dev
Related Topics: Google Cloud Platform