Mobile App language: React native
API language: Go
I have a mobile app which uses Google location service for GPS tracking. When the user come out a particular location then an API 1 is hit. In this API, another API 2 is called as a back end scheduler which executes some other functionality. The problem is the Google location service or something on the mobile app is calling API 1 multiple times due to which API 2 is also called multiple times. Hence breaking the system.
Implemented solution:
When the mobile app hits API 1, I have maintained a cache data in the database rather than calling API 2 immediately. Now to process the cache data I have introduced a cron job which will check every 5 minutes if there is any data in the cache, if found it will process it & do the functionality of API 2.
In the above solution the problem is that, I have to wait for 5 minutes to complete the process. Could there be any other solution so that I can call API 2 immediately or minimum time with accuracy ?