0

I am working on a project where I need to compare two json file which are fetched in two different time frames. basically It is a continuous crone function and it will get a new json reponse from the api for every 20 sec. and it should be compared with previous response.

I was using nodejs to do this and I could store the previous json response as file in the same folder and retrieve it for the next iteration. But this seems not working after I deploy it in Google cloud functions since the temp json file uploaded is not writable. Please suggest a way to read and write the content of same json file using google cloud functions.

1 Answer 1

1

It might not be possible to store a value inside memory of one cloud function invocation and retrieve that value during another cloud function invocation. We should be prepared that upon the cloud function has finished its execution, all memory may be released...

To overcome that limitation, one might have to find some external persistent location for value/object storage - that may be Cloud SQL, or Firestore, or Cloud Storage, or something else depending on other requirements and context restrictions.

I would probably start with storing objects in some cloud storage bucket, or use a firestore collection as a second option.

When developing such cloud function it might be a good idea to have in mind that the cloud function is supposed to be idempotent - see Write idempotent functions and Building idempotent functions

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.