Lambda Cache

https://katiyarvipinknp.medium.com/how-to-cache-the-data-in-aws-lambda-function-using-node-js-use-tmp-storage-of-aws-lambda-2c7e1e01d923

const cachedItem = {}; // as you know, anything declared outside the event handler function is reused between invocations.
exports.handler = (event, context, callback) => {
  let data;
  if (cachedItem && cachedItem.expiresOn > Date.now()) {
    // Fetch data from cache
    data = cachedItem.value;
  } else {
    // Set the data in cache
    setCachedData("tobecaheedvalue");
  }
  console.log("isDataCached", data);
}
const setCachedData = (val) => {
  cachedItem = {
    expiresOn: Date.now() + 3600 * 1000, // Set expiry time of 1H
    value: val
  }
}

Note: Once you update/deploy Lambda’s function then all the cached storage will automatically be removed.

Anything declared outside the event handler function is reused between invocations

Lambda global scope