Kronos-Android icon indicating copy to clipboard operation
Kronos-Android copied to clipboard

Cache and "refresh" behavior not clear

Open agforte opened this issue 5 years ago • 1 comments

If the cacheExpirationMs is 1 minute and minWaitTimeBetweenSyncMs is 5 minutes, what will happen when I do a getCurrentTime() at minute 3? Will the value in the cache be used even though it is expired, will a sync be forced even though it still has 2 minutes left or will it just use the local device time?

agforte avatar May 01 '20 15:05 agforte

By the look of the code, even if the last update is out of date, it'll still wait for the 5 minutes to expire before starting a new sync. The way this library works is by keeping in memory the difference between the local device time and the server time. Whenever you call getCurrentTime(), it will use this difference to return ASAP in a non blocking way, and will request a sync in the background if needed to ensure the difference is still accurate.

xgouchet avatar Aug 07 '20 07:08 xgouchet