I'm trying to implement a user service that has a GET and PUT API using AWS lambda , API gateway and Dynamo as the datastore
GET API will fetch the data for a given userId and PUT will update the user details for a given userId
My requirements are
since the throughput on the GET APIs are large I would need to cache the API response so that the response time is reduced in the subsequent requests. cache will also need to have a TTL.
Any successful put request on the same userId will invalidate the cache and subsequent GET request will fetch from DB and cache it again
I could possibly use a redis cluster for caching. But that might add addition VPC invocation overhead
Question:
- I'm using AWS lambda using serverless framework for the implementation. How should I go about designing the caching layer?
- Possible solutions include API gateway caching - But in this method how would I invalidate a cache incase of update requests