I’m working on a web mail client with gmails imap API as the backend. If I wanted to maintain a users emails in their inbox would I be better off using something like memcache to store the data received from the API calls? Or would it be better putting it in a database to call later?
Share
Both. Store the email in a db when getting the result set from the api. Also keep it in memcache. If nothing changes pull it from cache with a short life. Every so often refresh from the db on access if cache is stale. When checking api, if differences found in cached version, flush it, save results to db, then add new data to cache.
This should improve user experience and decrease api calls and db accesses.
Remember: everything including the db is just another cache layer–with different access characteristics and peformance trade offs.