Functions execute only in response to incoming data, but the environments that functions run in are generally long-running. Because of this, you can use global variables to cache small amounts of information between invocations. For example, you can reduce the number of access tokens you generate by caching a token, and regenerating it only after it expires. Segment cannot make any guarantees about the longevity of environments, but by using this strategy, you can improve the performance and reliability of your Functions by reducing the need for redundant API requests. This example code fetches an access token from an external API and refreshes it every hour: ```js const TOKEN_EXPIRE_MS = 60 * 60 * 1000 // 1 hour let token = null async function getAccessToken () { const now = new Date().getTime() if (!token || now - token.ts > TOKEN_EXPIRE_MS) { const resp = await fetch('https://example.com/tokens', { method: 'POST' }).then(resp => resp.json()) token = { ts: now, value: resp.token } } return token.value } ```