'Storing Auth Tokens that are used by Cloud Run services

I have an app running in a Cloud Run container, that communicates with multiple 3rd parties and therefore needs to provide auth headers to access their data. For some services, this auth token will need to be refreshed after a set time.

What is the best way to store these tokens so that they are shared across all instances of my cloud run containers, and so that if it needs to be updated multiple containers won't try to update it at once.

I thought about storing the token in a database, but then this increases read times and greater costs so isn't a very efficient method.

I know Memorycache could be used but would like to know if there are any other recommended ways.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source