Saturday, 3 December 2016

How to handle keeping data fresh in the background in Node/Express?

I made a React Native app that fetches events from an API but unfortunately they don't provide geolocation, just address. And they won't include the coordinates in their API, as I heard rumors they are deprecating the API in favor of a better one soon.So the issue is that I request a weeks worth of events and then geocode them all one after another (could be optimized, yes). But I thought it could make more sense to do it on a server, so that the app doesn't have to do that logic.I have a server which fetches the data from the API and then sends it back, a simple proxy. Also I'm possibly turning it into a GraphQL endpoint.I'm trying to figure out what is the most sensible option to cache, or keep in memory/db the events that are already geocoded and how and when to geocode and refresh them.Options I've considered:hourly/daily cron that fires a script that fetches and syncs to a dbRedis caching the requestsworker thread to do basically the same job as the cron wouldjust saving the events into memory and then just passing those around if they aren't stale yet (~hourly refetch)What would be the best solution? I'm a junior dev and this area is new to me, so any help and pointers are appreciated. I'm not too excited about a solution that would be slow for the users, which the caching would do.

Submitted December 03, 2016 at 03:25PM by Turma

No comments:

Post a Comment