Caching between lambda invocations may be useful for certain scenarios:
- Rate limits with external services
How to cache between lambda invocations
In Python, it’s as simple as modifying a global variable.
Upon initial run of a lambda function,
obj will be set to the output of
YourClass(event). On subsequent warm starts, the lambda function will reuse the global
obj from the previous lambda run. More information regarding warm vs cold starts can be found here.